I have a LocalDateTime property in my entity class, but when it's serialized, I don't see the expected format.
This is the class:
public class MyEntity {
private Integer id;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'")
private LocalDateTime changeDate;
// getters and setters
}
This is how jackson is formatting it:
{
"id": 56,
"changeDate": {
"hour":14, "minute":19,
"nano":797000000,
"second":7,
"dayOfMonth":24,
"dayOfWeek":"TUESDAY",
"dayOfYear":297, "month":"OCTOBER",
"monthValue":10,
"year":2017,
"chronology": {
"id":"ISO",
"calendarType":"iso8601"
}
}
}
Note that I added the following dependency to my pom:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
I don't include the version because spring boot takes care of that. By the way I'm using spring boot 1.5.2.RELEASE.
I also included the following property in application.properties:
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false
Any idea why the date is not formatted with like that instead of using the pattern I provided?