I have a Java Timestamp value like: 1799-12-31 19:03:58.0 And when I try to convert it into the OffsetDateTime using the code:
It gives me the output as:
Which is not getting parsed at frontend (Angular’s date pipe). But the same code returns the different offset for the timestamp: 2019-08-24 10:15:22.0 as:
Which is valid and successfully gets parsed by Angular’s date pipe.
I am not getting why it is returning different offset for the ‘1799-12-31 19:03:58.0’ date.
Short answer: history.
Judging by the weird
05:53:28 offset, your current zone is
← well, this timezone has been renamed to
Back in 1799, each city had its own local time, which is why this offset is strange. Timezones are often changed due to political decisions, and Java gets this data from the timezone data shipped along with each Java release.
So those different offsets are actually correct.
If your frontend cannot parse this strange offset, then you need to fix your frontend.
More information and similar observations:
- Why is subtracting these two times (in 1927) giving a strange result?
- DateFormatter gives weird timezone for very old dates
- Providing date string with offsets (+0530) vs specifying timezone separately in display name (Asia/Calcutta)
- Java OffsetDateTime returning wrong offset