Cannot deserialize `OffsetDateTime.MIN` or `OffsetDateTime.MAX` with `ADJUST_DATES_TO_CONTEXT_TIME_ZONE` enabled
See original GitHub issueThis probably relates to #124.
I cannot deserialize OffsetDateTime.MIN
and OffsetDateTime.MAX
.
With jackson-databind
and jackson-datatype-jsr310
(both 2.10.3) on my class path the following works:
ObjectMapper o = new ObjectMapper();
o.findAndRegisterModules();
o.readValue("\"" + OffsetDateTime.now().toString() + "\"", OffsetDateTime.class);
The following does not work:
// (OffsetDateTime.MIN is -999999999-01-01T00:00+18:00)
o.readValue("\"" + OffsetDateTime.MIN.toString() + "\"", OffsetDateTime.class);
// Or:
// (OffsetDateTime.MAX is +999999999-12-31T23:59:59.999999999-18:00)
o.readValue("\"" + OffsetDateTime.MAX.toString() + "\"", OffsetDateTime.class);
Removing the offset or shifting the time by the respective amount of hours seems to work again:
o.readValue("\"-999999999-01-01T00:00+18:00\"", OffsetDateTime.class); // doesn't work
o.readValue("\"-999999999-01-01T18:00+18:00\"", OffsetDateTime.class); // works
o.readValue("\"-999999999-01-01T00:00+00\"", OffsetDateTime.class); // works
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Cannot deserialize value of type `java.time.OffsetDateTime ...
Following my comment in the question, I realize you don't need a Jackson annotation. You just need to adjust the setter.
Read more >OffsetDateTime (Java Platform SE 8 ) - Oracle Help Center
OffsetDateTime is an immutable representation of a date-time with an offset. This class stores all date and time fields, to a precision of...
Read more >OffsetDateTime - Android Developers
The minimum supported OffsetDateTime , '-999999999-01-01T00:00:00+18:00'. ... Throws. DateTimeException, if unable to convert to an OffsetDateTime ...
Read more >OffsetDateTime in time - Rust - Docs.rs
Attempt to create a new OffsetDateTime with the current date and time in the local offset. If the offset cannot be determined, an...
Read more >Shared API for package java.time - Elastic
static OffsetDateTime MAX; static OffsetDateTime MIN; static OffsetDateTime from(TemporalAccessor); static OffsetDateTime of(LocalDateTime, ZoneOffset) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think either would work as these values seem unlikely to serve anything more than as markers. So probably first one, being simpler?
I wonder if code has assumption that values, but in UTC, would be limits? And thereby actual min/max would be considered to be outside, since normalized date (once value normalized to UTC) would then fall outside numeric values, in both cases.