@Configuration
public class JacksonConfig {
@Bean
JacksonProperties jacksonProperties() {
JacksonProperties properties = new JacksonProperties();
properties.setDateFormat(DateHandler.DATETIME_PATTERN);
properties.setJodaDateTimeFormat(DateHandler.DATETIME_PATTERN);
properties.setTimeZone(TimeZone.getTimeZone(DateHandler.ZONEID));
properties.getSerialization().put(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
return properties;
}
@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
return builder -> {
builder.serializerByType(LocalDate.class, new LocalDateSerializer(DateHandler.DATE_FORMAT));
builder.deserializerByType(LocalDate.class, new LocalDateDeserializer(DateHandler.DATE_FORMAT));
builder.serializerByType(LocalTime.class, new LocalTimeSerializer(DateHandler.TIME_FORMAT));
builder.deserializerByType(LocalTime.class, new LocalTimeDeserializer(DateHandler.TIME_FORMAT));
builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(DateHandler.DATETIME_FORMAT));
builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(DateHandler.DATETIME_FORMAT));
};
}
}