In a DTO, I can get a date string converted to a java.util.Date, using the com.fasterxml.jackson.annotation.JsonFormat annotation:
class myDTO {
@JsonFormat(pattern="MM/dd/yyyy")
private Date theDate;
// accessors, etc...
}
Not so when the property is of type java.util.LocalDate...
How do I make it work?
Using jackson-databind-2.4.1
Thanks!
JavaTimeModulemodule. Take a look at jackson-modules-java8, Jackson Serialize Instant to Nanosecond Issue, Spring Boot Jackson date and timestamp FormatSpring Bootit should pick upJavaTimeModulemodule automatically if it will be on class path. So, adding dependency would be a good start. If not, you need to create customObjectMapperinstance and register module manually. Take a look at Customize the Jackson ObjectMapper for an example. Which version ofSpringdo you use?spring-mvc(v4. See title/tags), notspring-boot. Thanks for the links, but those look like they'respring-boot-specific.