Deserialize “Zulu” time in ISO8601 format in jackson

前端 未结 3 1526
傲寒
傲寒 2021-01-19 14:16

I have a need to de-serialize time of format 2016-11-28T10:34:25.097Z using Jackson into ZonedDateTime of Java8.

I believe I correctly configured O

3条回答
  •  迷失自我
    2021-01-19 14:29

    I needed to serialize/deserialize a date in ISO8601 Zulu format 2016-11-28T10:34:25.097Z like you

    I chose to change the date formatter in ObjectMapper using ISO8601DateFormat

    like this

    @Bean
    ObjectMapper getObjectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        // some other config...
        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        objectMapper.setDateFormat(new ISO8601DateFormat());
        return objectMapper;
    }
    

提交回复
热议问题