Skip to content

@JsonFormat is ignored by the DateSerializer unless either a custom pattern or a timezone are specified #1109

Closed
@aseovic

Description

@aseovic

If the user simply specifies @JsonFormat annotation with string shape, the shape is ignored and the date is serialized as long:

static class Person
{
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    public Date dateOfBirth;
}

gets serialized as:

{"dateOfBirth":1198800000000}

I believe the correct behavior should be to write the date as a string in ISO8601 format.

If you agree I will implement the fix and create a PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions