Jackson loses time offset from dates when deserializing to JodaTime
Yes, this is by design. JodaTime DateTimeSerializer
use standard toString() method. According to JodaTime official guide toString()
returns - the standard ISO8601 string for the DateTime. Also, standard DateTimeDeserializer
always creates UTC datetimes.
To store TimeZone you need to store it separately with same json and use .withZone()
method after deserialization or just create serializer and deserializer.
UPDATE
Version 2.2.3 have a bit extended behaviour - DateTimeDeserializer
creates DateTime with timeZone taken from DeserializationContext
. it may be changed with ObjectMapper.setTimeZone()
. Default is TimeZone.getTimeZone("GMT")
Jackson must be told to not adjust the time-zone to that of the local context by:
mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
See this issue on GitHub