Jackson Encoding Date Class

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Jackson Encoding Date Class

LargoUsagi
This post has NOT been accepted by the mailing list yet.
I am trying to get jackson to encode a Date object to a string type.  I have tried including

<dependency>
  <groupId>com.fasterxml.jackson.datatype</groupId>
  <artifactId>jackson-datatype-joda</artifactId>
  <version>2.4.0</version>
</dependency>   

In my pom and nothing changed.

This is the method

@Get("Json")
public List<BunkerDto> getBunkers() {
        return applicationBunkerService.getBunkers();
}

and here is what I am getting

[
{
"id": 1,
"name": "Pentagon",
"scorePerMinute": 2,
"objectiveControls": [
{
"id": 2,
"team": {
"id": 2,
"color": "Blue",
"colorCode": "blue",
"name": "Blue"
},
"time": 1405573200000
},
{
"id": 1,
"team": {
"id": 1,
"color": "Red",
"colorCode": "red",
"name": "Red"
},
"time": 1405569600000
}
]
}
]

The time field is being encoded as seconds from the epoch making it difficult to use on front ends.

I would prefer to keep the implicit serialization.
Loading...