Skip to content

Instant, YearMonth and MonthDay not use pattern in @JsonFormat #101

Closed
@devdevx

Description

@devdevx

I'm trying to define a custom patterns for this classes but sems that the @JsonFormat is ignored.

Jackson version: 2.9.3
Jackson datatype version: 2.9.6

Example of @JsonFormat anotation:

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy HH_mm_ss_SSS|z")
    private Instant customInstant;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM")
    private YearMonth customYearMonth;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM_dd")
    private MonthDay customMonthDay;

Current result:

When serialize the fields are formated with the default pattern and when deserialize a exception is throw.

Expected result:

Serialization and deserialization works sucessfully using the defined pattern.

Thanks !

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