Skip to content

Commit

Permalink
Fix for FasterXML#1154
Browse files Browse the repository at this point in the history
Partially roll back to pre-FasterXML#1111 behavior.
We just make sure that the STRING shape is chosen when Shape.ANY (the default) is set on the annotation, but some other annotation attribute was also set (pattern, locale or timezone).
This way of fixing the issue has the added benefit of respecting the user config regarding the default serialization of dates when @jsonformat(shape = Shape.ANY) is set on a property.
  • Loading branch information
yrodiere committed Mar 9, 2016
1 parent c5fba8a commit 16cb352
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ public JsonSerializer<?> createContextual(SerializerProvider serializers,
return withFormat(Boolean.TRUE, null);
}

if (format.getShape() == JsonFormat.Shape.STRING) {
if (format.getShape() == JsonFormat.Shape.STRING || format.hasPattern()
|| format.hasLocale() || format.hasTimeZone()) {
TimeZone tz = format.getTimeZone();
final String pattern = format.hasPattern()
? format.getPattern()
: StdDateFormat.DATE_FORMAT_STR_ISO8601;
? format.getPattern()
: StdDateFormat.DATE_FORMAT_STR_ISO8601;
final Locale loc = format.hasLocale()
? format.getLocale()
: serializers.getLocale();
? format.getLocale()
: serializers.getLocale();
SimpleDateFormat df = new SimpleDateFormat(pattern, loc);
if (tz == null) {
tz = serializers.getTimeZone();
Expand Down

0 comments on commit 16cb352

Please sign in to comment.