Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Time zone aware lenient parsing #343

Closed
wants to merge 1 commit into from

Conversation

hpoettker
Copy link

Resolves #342.

The current implementation of lenient parsing of LocalDate and LocalDateTime was implemented with the goal to always produce the values such that they need to be interpreted to be UTC.

In particular for LocalDate this can very easily lead to confusing behavior for users.

The proposed change only leads to a change in behavior when the TimeZone is explicitly set on the ObjectMapper and is different from UTC.

ObjectReader reader = READER.with(TimeZone.getTimeZone(Z_BUDAPEST));
Instant instant = Instant.parse("2024-07-21T22:00:00Z");
LocalDate value = reader.readValue('"' + instant.toString() + '"');
assertEquals("The value is not correct.", LocalDate.parse("2024-07-22"), value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong and against the semantics of LocalDate.

@cowtowncoder
Copy link
Member

I'll continue discussion on #342 but basically I do not agree with the change as is.

Mis-using LocalDate to take in zoned-values may have been a mistake all along, but I don't want to compound be making it even more ill-conceived.

In this case you will probably need to register custom deserializer to solve your use case.

@hpoettker
Copy link
Author

I understand your objections. Then let's close this one.

@hpoettker hpoettker closed this Jan 23, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lenient deserialization of LocalDate is not time-zone aware
2 participants