Jackson deserialize ISO8601 formatted date-time into Java8 Instant

后端 未结 5 1967
傲寒
傲寒 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:34

    You need to set the explicit time zone via XXX in your modell class:

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
    

    (see: https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html)

提交回复
热议问题