Open
Description
Version: 2.8.8
Below is the test code:
LocalDateTime localDateTime = new LocalDateTime(2017, 1, 1, 1, 1, 1);
ZonedDateTime java8ZonedDateTime = ZonedDateTime.ofInstant(localDateTime.toDate().toInstant(), ZoneId.of("Asia/Shanghai"));
DateTime jodaDateTime = localDateTime.toDateTime(DateTimeZone.forID("Asia/Shanghai"));
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JodaModule());
objectMapper.registerModule(new JavaTimeModule());
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
System.out.println(objectMapper.writeValueAsString(java8ZonedDateTime));
System.out.println(objectMapper.writeValueAsString(jodaDateTime));
ZonedDateTime
result is "2017-01-01T01:01:01+08:00"
while DateTime
result is "2016-12-31T17:01:01.000Z"
, which is convert to UTC timezone.