-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
DateTimeSerializerBase#createContextual
creates a new serializer with StdDateFormat.DATE_FORMAT_STR_ISO8601
format instead of re-using the actual format that may have been specified on the configuration. See the following code:
final String pattern = format.hasPattern()
? format.getPattern()
: StdDateFormat.DATE_FORMAT_STR_ISO8601;
Using the @JsonFormat
annotation on a field will therefore reset the format to Jackson's default even if the annotation doesn't specify any custom format.
DateBasedDeserializer#createContextual
behaves differently and tries to re-use the configured format:
DateFormat df = ctxt.getConfig().getDateFormat();
// one shortcut: with our custom format, can simplify handling a bit
if (df.getClass() == StdDateFormat.class) {
...
StdDateFormat std = (StdDateFormat) df;
std = std.withTimeZone(tz);
...
} else {
// otherwise need to clone, re-set timezone:
df = (DateFormat) df.clone();
df.setTimeZone(tz);
}
Shouldn't the serializer follow the same approach ?
Metadata
Metadata
Assignees
Labels
No labels