-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Closed
Copy link
Milestone
Description
Since #1111 was merged, JsonFormat.pattern
is now only taken into account if the shape is set to STRING
. When leaving the default shape (ANY
), the pattern is ignored.
Thus this works:
public class Person
{
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-mm-dd")
public Date dateOfBirth;
}
But this doesn't (anymore):
public class Person
{
@JsonFormat(pattern = "yyyy-mm-dd") // Uses default shape, which is ANY
public Date dateOfBirth;
}
From what I understand of DataTimeSerializerBase's code, it seems that the default "shape" for a date-time is a String (see how _asTimestamp
returns false by default). So it seems that providing a pattern should work with the shape ANY
, which means "the default shape", which is STRING
.
The issue stems from this line . It should be something like this instead:
if (format.getShape() == JsonFormat.Shape.STRING || format.getShape() == JsonFormat.Shape.ANY) {
PR coming as soon as I have the issue ID.
Metadata
Metadata
Assignees
Labels
No labels