[ 
https://issues.apache.org/jira/browse/NIFI-12866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17827767#comment-17827767
 ] 

Lehel Boér commented on NIFI-12866:
-----------------------------------

The date conversion issue comes from how Instant represents time as epoch 
millis from the first (default) epoch (1970-01-01) and how it is represented in 
an actual Julian calendar in a Date object. There are day skips, leap second so 
that an arbitrary point in time especially with historical dates can be 
represented differently. (E.g. in 1582-10, ten days vanished because of the 
switch from Julian calendar to Gregorian calendar).

> DataTypeUtils long to Timestamp conversion may not handle historical dates 
> correctly
> ------------------------------------------------------------------------------------
>
>                 Key: NIFI-12866
>                 URL: https://issues.apache.org/jira/browse/NIFI-12866
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Lehel Boér
>            Assignee: Lehel Boér
>            Priority: Major
>
> * NiFi version: 1.25.0
>  * Slack discussion: 
> https://apachenifi.slack.com/archives/C0L9VCD47/p1709571300887339
> When inserting default time -62135596800000 (0001-01-01) from NiFi to 
> PostgreSQL, it results in 0001-01-03.
> The conversion happens in DataTypeUtils::toTimeStamp.
>  
>  
> {code:java}
> if (value instanceof Number) {
>     final long longValue = ((Number) value).longValue();
>     return new Timestamp(longValue);
> } {code}
>  
>  
> When Java created a new Timestamp, it constructs a Date object internally.
> When creating a Date object witht he same value it is also shifted.
> {code:java}
> Date date = new Date(-62135596800000L);
> 1-01-02T19:00:00.000-0500" {code}
>  
> This issue needs to be investigated.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to