Jackson deserialize ISO8601 formatted date-time into Java8 Instant

后端 未结 5 1962
傲寒
傲寒 2021-02-03 18:02

I\'m trying to deserialize an ISO8601 formatted date into Java8 java.time.Instant using Jackson. I registered JavaTimeModule with the ObjectMapper, and turned off t

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 18:49

    Jackson can be configured globally (without annotations) to accept timestamps with or without colon:

    ObjectMapper mapper = new ObjectMapper();
    mapper.setDateFormat(new StdDateFormat().withColonInTimeZone(true));
    

    The default Jackson timezone format was changed since version 2.11 from '+0000' to '+00:00'. Both formats are valid according to ISO-8601.

提交回复
热议问题