For java.util.Date when I do
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = \"dd/MM/yyyy\")
private Date dateOfBirth;
<
Just an update of Christopher answer.
Since the version 2.6.0
com.fasterxml.jackson.datatype
jackson-datatype-jsr310
2.9.0
Use the JavaTimeModule instead of JSR310Module (deprecated).
@Provider
public class ObjectMapperContextResolver implements ContextResolver {
private final ObjectMapper MAPPER;
public ObjectMapperContextResolver() {
MAPPER = new ObjectMapper();
MAPPER.registerModule(new JavaTimeModule());
MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
@Override
public ObjectMapper getContext(Class> type) {
return MAPPER;
}
}
According to the documentation, the new JavaTimeModule uses same standard settings to default to serialization that does NOT use Timezone Ids, and instead only uses ISO-8601 compliant Timezone offsets.
Behavior may be changed using SerializationFeature.WRITE_DATES_WITH_ZONE_ID