Jackson serializes a ZonedDateTime wrongly in Spring Boot

前端 未结 4 1849
有刺的猬
有刺的猬 2021-02-05 01:28

I have a simple application with Spring Boot and Jetty. I have a simple controller returning an object which has a Java 8 ZonedDateTime:

public clas         


        
4条回答
  •  囚心锁ツ
    2021-02-05 02:06

    If you either don't rely on SpringBoot's auto-configuration feature - you don't provide spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false property into your configuration file - or for whatever reason you create ObjectMapper instance manually. You can disable this feature programatically as follows:

    ObjectMapper m = new ObjectMapper();
    m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    

    this is for jackson 2.8.7

提交回复
热议问题