2

I'm using springBoot to develop a REST APi. And i have a LocalDate field "firstDate" in the response model of a GET endpoint. But this LocalDate is serializable as an array in the response's json!

"firstDate": [
        2021,
        3,
        1
      ],

So for consuming this APi, i have to define this date in my DTO as an array! which is not good! My reponse models of th API are generated with swagger so i can not use @JsonFormat(pattern="yyyy-MM-dd")

Can you help me please and tell me how to serialize LocalDate properly in this case ?

Thank you very much.

Rubis
  • 21
  • 1
  • Have your tried this ``` @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JodaModule()); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); return mapper; } ``` – Ilam Mar 14 '21 at 12:45
  • 1
    Does this answer your question? [Configure LocaldateTime in Spring Rest API](https://stackoverflow.com/questions/53365917/configure-localdatetime-in-spring-rest-api) – Simon Martinelli Mar 14 '21 at 13:17

0 Answers0