Skip to content

ZonedDateTime serialization with @JsonFormat.pattern never uses it while WRITE_DATES_WITH_ZONE_ID enabled #333

Closed
@verve111

Description

@verve111

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

Hi, I'm using JavaTimeModule() in my app with SerializationFeature.WRITE_DATES_WITH_ZONE_ID enabled and there's a strange thing:
When JsonFormat-annotation with pattern is added:

    static class SomeDto {
        @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss z")
        private ZonedDateTime time;
    }

Current object is always serialized as an ISO_ZONED_DATE_TIME, e.g. "2024-11-15T18:27:06.921054+01:00[Europe/Germany]", the pattern is not taken into account.
Could you give a hint if this is expected behaviour, thank you!

Version Information

2.18.1

Expected behavior

{"time":"2024-12-02 16:30:00 CET"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions