[Bug]: Select values (and JSON input) - unable to convert string timestamps
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 476
- Avg merge
- 18h 32m
- Merged PRs (30d)
- 216
Description
### Apache Hop version?
2.11.0
### Java version?
17.0.2
### Operating system
Linux
### What happened?
Set up a **Select values** transform in order to convert a `String` in the form `2025-02-13T02:10:14.746582` in a `Timestamp` or `Date` object with format `yyyy-MM-dd'T'HH:mm:ss.SSSXXX`.
When trying to convert it to a `Timestamp`, the error reported is:
```
2025/02/14 11:04:53 - Formato output.0 - ERROR: Unexpected error
2025/02/14 11:04:53 - Formato output.0 - ERROR: java.lang.NullPointerException: Cannot invoke "java.util.Date.getTime()" because "tempDate" is null
2025/02/14 11:04:53 - Formato output.0 - at org.apache.hop.core.row.value.timestamp.SimpleTimestampFormat.parse(SimpleTimestampFormat.java:341)
2025/02/14 11:04:53 - Formato output.0 - at java.base/java.text.DateFormat.parse(DateFormat.java:397)
2025/02/14 11:04:53 - Formato output.0 - at org.apache.hop.core.row.value.timestamp.SimpleTimestampFormat.parse(SimpleTimestampFormat.java:448)
2025/02/14 11:04:53 - Formato output.0 - at org.apache.hop.core.row.value.ValueMetaTimestamp.convertStringToTimestamp(ValueMetaTimestamp.java:262)
2025/02/14 11:04:53 - Formato output.0 - at org.apache.hop.core.row.value.ValueMetaTimestamp.convertData(ValueMetaTimestamp.java:424)
2025/02/14 11:04:53 - Formato output.0 - at org.apache.hop.pipeline.transforms.selectvalues.SelectValues.metadataValues(SelectValues.java:347)
2025/02/14 11:04:53 - Formato output.0 - at org.apache.hop.pipeline.transforms.selectvalues.SelectValues.processRow(SelectValues.java:402)
2025/02/14 11:04:53 - Formato output.0 - at org.apache.hop.pipeline.transform.RunThread.run(RunThread.java:54)
2025/02/14 11:04:53 - Formato output.0 - at java.base/java.lang.Thread.run(Thread.java:833)
```
When trying to convert it into a `Date`, this is the error reported:
```
2025/02/14 11:08:39 - Formato output.0 - ERROR: Unexpected error
2025/02/14 11:08:39 - Formato output.0 - ERROR: org.apache.hop.core.exception.HopConversionException:
2025/02/14 11:08:39 - Formato output.0 -
2025/02/14 11:08:39 - Formato output.0 - create_date String : couldn't convert string [2025-02-13T02:10:14.746582] to a date using format [yyyy-MM-dd'T'HH:mm:ss.SSSXXX] on offset location 26
2025/02/14 11:08:39 - Formato output.0 - 2025-02-13T02:10:14.746582
2025/02/14 11:08:39 - Formato output.0 -
2025/02/14 11:08:39 - Formato output.0 -
2025/02/14 11:08:39 - Formato output.0 - at org.apache.hop.pipeline.transforms.selectvalues.SelectValues.metadataValues(SelectValues.java:353)
2025/02/14 11:08:39 - Formato output.0 - at org.apache.hop.pipeline.transforms.selectvalues.SelectValues.processRow(SelectValues.java:402)
2025/02/14 11:08:39 - Formato output.0 - at org.apache.hop.pipeline.transform.RunThread.run(RunThread.java:54)
2025/02/14 11:08:39 - Formato output.0 - at java.base/java.lang.Thread.run(Thread.java:833)
```
Similar issues happen with the **JSON Input** transform, when trying to read those string timestamps directly as `Timestamp` or `Date`.
### Issue Priority
Priority: 2
### Issue Component
Component: Transforms
Contributor guide
Research direction
Reproduce the conversion through the SelectValues and JSON Input transforms using the sample timestamp and format. Start with org.apache.hop.core.row.value.timestamp.SimpleTimestampFormat and ValueMetaTimestamp, then inspect SelectValues.metadataValues; done means the reported string timestamp conversion behavior is covered and the failing cases are resolved with regression tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100