Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 2
    Thanks. So I added the jackson-datatype-jsr310 version 2.8.1 dependency, and the effect was that the timestamp changed to a double "lastUpdated":1471893818.177000000. In Spring Boot I don't have direct access to the ObjectMapper it is using, any idea where do I tell it to use the JavaTimeModule? (I am a bit new to Spring Boot) Commented Aug 22, 2016 at 19:25
  • @jbx check this answer - stackoverflow.com/questions/7854030/… also you need to try turning off WRITE_DATES_AS_TIMESTAMPS feature to convert datetime to ISO-8601 Commented Aug 22, 2016 at 19:28
  • Was just going to tell you I found the answer. Yes it works, just by spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false, no need to programmatically customise the ObjectMapper. Since my question was specifically about Spring boot, can you edit your answer to add this so that I choose it as the right answer? Commented Aug 22, 2016 at 19:30
  • @jbx great! glad you solved it completely. Thanks, I'll edit my answer Commented Aug 22, 2016 at 19:32
  • For my solution to my problem, this answer may still be missing the convenience method .findAndRegisterModules(), which is functionally equivalent to mapper.registerModules(findModules()). So when outputting the serialization, it may look like this: new ObjectMapper.findAndRegisterModules().writeValueAsString(requestObject), where requestObject could be some entity or parameter. Commented Apr 12, 2020 at 22:16