-
Notifications
You must be signed in to change notification settings - Fork 85
Description
In this commit, for DateTimeSerializer:
cf2f4c2#diff-86756f80e06fe3b0a847c963534b14baR55
DateTime.parse()
is replaced by using the JacksonJodaDateFormat
, which defaults to FormatConfig.DEFAULT_DATETIME_FORMAT
, which is defined as new JacksonJodaDateFormat(ISODateTimeFormat.dateTime().withZoneUTC())
.
DateTime.parse()
uses ISODateTimeFormat.dateTimeParser().withOffsetParsed()
:
http://www.joda.org/joda-time/apidocs/org/joda/time/DateTime.html#parse-java.lang.String-
So ultimately, the default date time parser format has changed from ISODateTimeFormat.dateTimeParser()
to ISODateTimeFormat.dateTime()
. Although similar, ISODateTimeFormat.dateTimeParser()
is much less restrictive:
http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTimeParser--
As an example, the datetime "2015-07-27T08:11:07-07:00" is missing the .SSS
milliseconds value, so it fails in 2.6.0 but works in 2.5.4:
Caused by: java.lang.IllegalArgumentException: Invalid format: "2015-07-27T08:11:07-07:00" is malformed at "-07:00"
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:899) ~[joda-time-2.8.1.jar:2.8.1]
at com.fasterxml.jackson.datatype.joda.deser.DateTimeDeserializer.deserialize(DateTimeDeserializer.java:90) ~[jackson-datatype-joda-2.6.0.jar:2.6.0]
at com.fasterxml.jackson.datatype.joda.deser.DateTimeDeserializer.deserialize(DateTimeDeserializer.java:22) ~[jackson-datatype-joda-2.6.0.jar:2.6.0]
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:520) ~[jackson-databind-2.6.0.jar:2.6.0]
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101) ~[jackson-databind-2.6.0.jar:2.6.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:256) ~[jackson-databind-2.6.0.jar:2.6.0]
A workaround in this situation is to add a @JsonFormat
annotation to the property specifying the specific format, e.g: @JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ssZZ")