-
Notifications
You must be signed in to change notification settings - Fork 118
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
Lenient deserialization of LocalDate
, LocalDateTime
is not time-zone aware
#342
Comments
But I am not sure why As far as I know, behavior really should be such that any time portion (and timezone, if one given) would be dropped. I disagree in that timezone should have any effect on abstract Date portion. |
Thanks for the quick reply! I live in time zone offset I agree that the time should just be dropped when deserializing to a |
I don't think I really understand the ask here. So, with given input |
The ask is to have an easy option that allows a time zone to be reflected in the lenient deserialization of The reasoning is that This mapping from a point in time to the corresponding calendar day would be useful to have, at least in lenient mode. Example 1The input would be for example
and the deserialization target would be
Currently, the deserialization fails if leniency is disabled and produces a record with the When a time zone with an offset of Example 2Analogously, we can consider the example
With lenient deserialization this currently always produces a With a time zone like |
Ok, if there was a module configuration setting that allows use of TimeZone, as described, but default to It should be relatively to add this by using Thank you for working with me here @hpoettker. |
LocalDate
is not time-zone awareLocalDate
, LocalDateTime
is not time-zone aware
The deserialization code in
LocalDateDeserializer
contains lenient logic to also accept strings like2025-01-21T23:00:00Z
and deserialize this to aLocalDate
: https://github.com/FasterXML/jackson-modules-java8/blob/2.19/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserializer.java#L164The problem is that this example timestamp will always be deserialized to
2025-01-21
, although in time zones with a positive offset (e.g. Central European Time = +01:00), this is unexpected and a source of errors for users.My use case is also a JavaScript client communicating with a Java backend (as motivated in one of the comments in the code) and I appreciate the idea. But I think the conversion should be time-zone aware. Strings ending with
Z
could e.g. be parsed asInstant
s which could then be transformed to aLocalDate
according to the JVM's defaultTimeZone
or theTimeZone
that has been set on theObjectMapper
.The text was updated successfully, but these errors were encountered: