alessandro ferrucci
alessandro ferrucci

Reputation: 1289

Jackson 2.4.2 Date serialization not milliseconds

I'm using Spring MVC 3.2.x with Jackson 2.4.2 for JSON web services.

I have objects that contain java.util.Date and the JSON contains a string representation of just the date portion: ("2014-09-15"). this goes against the Jackson documentation that says dates by default get marshalled as milliseconds epoch format (http://wiki.fasterxml.com/JacksonFAQDateHandling).

I would like the date members to be returned as milliseconds format, what am I missing here?

Here is my jackson libraries in my pom file:

<dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.4.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.4.2</version>
    </dependency>

I have annotation-driven in my applicationContext:

Thanks! Alessandro Ferrucci

Upvotes: 2

Views: 2534

Answers (1)

charybr
charybr

Reputation: 1948

In my case, problem was in Spring Data REST(2.2.1) disabling WRITE_DATES_AS_TIMESTAMPS by default. I am sure Spring MVC might be doing the same, but I unable to locate that code-commit.

However I was able to locate code-commit in case of Spring Data REST:

Upvotes: 1

Related Questions