alexanoid
alexanoid

Reputation: 25802

Spring Boot Jackson and Data serialization

In my Spring Boot application I use a following DTO with @RestController:

public abstract class ComparableQuery extends BaseQuery {

    private final Object value;

...

}

Everything works fine but when I use Spring RestTemplate and pass java.util.Date as ComparableQuery.value I see that Jackson serialize the date object into the following "magic" number:

"value":1009836000000

Right now I don't understand how the date object serialized into the 1009836000000 number representation and how to emulate it when I use for example AngularJS as a client of my back-end API. Please advise.

Upvotes: 1

Views: 1961

Answers (1)

Jörn Horstmann
Jörn Horstmann

Reputation: 34024

This is a very similar problem as described in this answer about null handling with jackson and spring boot.

The corresponding configuration for date formatting in application.properties should look like:

spring.jackson.write-dates-as-timestamps=false

Upvotes: 2

Related Questions