Skip to content

ZonedDateTime serialize with @JsonFormat pattern never uses it, and then while deserialization can't parse it #3057

@verve111

Description

@verve111

Hi, I'm using JavaTimeModule() in spring-data-redis implementation of my app and there's a strange thing:
When JsonFormat-annotation with pattern is added:

data class CacheValue(
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    val zonedDateTime: ZonedDateTime
)

Current object is always stored in Redis as an ISO_ZONED_DATE_TIME, e.g. "2024-11-15T18:27:06.921054+01:00[Europe/Germany]", the pattern is not taken into an account.
But then when deserialization comes, it tries to deserialize the ISO_ZONED_DATE_TIME formatted object from Redis with "yyyy-MM-dd'T'HH:mm:ss.SSSZ" pattern and fails.
Could you please give a hint, what is wrong here. I guess jackson serializer supposed to use pattern to encode the date, thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions