Skip to content

Lenient deserialization of LocalDate, LocalDateTime is not time-zone aware #342

Closed
@hpoettker

Description

@hpoettker

The deserialization code in LocalDateDeserializer contains lenient logic to also accept strings like 2025-01-21T23:00:00Z and deserialize this to a LocalDate: https://github.com/FasterXML/jackson-modules-java8/blob/2.19/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateDeserializer.java#L164

The 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 as Instants which could then be transformed to a LocalDate according to the JVM's default TimeZone or the TimeZone that has been set on the ObjectMapper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions