question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot deserialize `OffsetDateTime.MIN` or `OffsetDateTime.MAX` with `ADJUST_DATES_TO_CONTEXT_TIME_ZONE` enabled

See original GitHub issue

This 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:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, May 16, 2020

I think either would work as these values seem unlikely to serve anything more than as markers. So probably first one, being simpler?

1reaction
cowtowncodercommented, Mar 18, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found