0

I am using LocalDateTime in spring boot application and i am storing date and time in ISO format in mongodb and it is also getting stored there but when I am making API calls to the end points of my application it is showing list of numbers instead of showing the date in ISO format you can also see

enter image description here

enter image description here

Here is the class enter image description here

I am not getting why it is working like this way.

Nitesh Singh
  • 45
  • 1
  • 9
  • Where are you using the `LocalDateTime`? Can you show the conversion or at least where in your code you are using that class? A little remark: For an ISO formatted `String` including the `Z` at the end (*Zulu* or just UTC) you'd be better off using an `OffsetDateTime`, I think, maybe even a `ZonedDateTime`. – deHaar Apr 26 '22 at 13:41
  • Yes I have added the screenshot of that now. @deHaar – Nitesh Singh Apr 26 '22 at 13:45
  • 3
    You are probably using Jackson for the conversion to JSON and Jackson unfortunately does the wrong thing by default. You have to configure it yourself to use ISO-8601 format. See this article: [Formatting JSON Dates in Spring Boot](https://www.baeldung.com/spring-boot-formatting-json-dates) – Jesper Apr 26 '22 at 14:33

0 Answers0