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
There is a library jackson-datatype-jsr310. Try it.
This library covers new datetime API and includes serializers for ZonedDateTime
too.
All you need is just to add JavaTimeModule
:
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
UPDATE
To convert datetime to ISO-8601 string you should disable WRITE_DATES_AS_TIMESTAMPS feature. You can easily do by either overriding ObjectMapper
bean or by using application properties:
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false