jsondateserializationspring-bootspring-data-rest

Spring Boot LocalDate field serialization and deserialization


In Spring Boot 1.2.3.RELEASE with fasterxml what is the correct way of serializing and de-serializing a LocalDate field to ISO date formatted string?

I've tried:

None of the above helped.


Solution

  • compile ("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
    

    in build.gradle and then following annotations helped:

    @JsonDeserialize(using = LocalDateDeserializer.class)
    @JsonSerialize(using = LocalDateSerializer.class)
    private LocalDate birthday;
    

    Update: if you are using Spring Boot 2.*, the dependency is already included via one of the "starters".