List of usage examples for com.fasterxml.jackson.datatype.jsr310 JavaTimeModule addSerializer
public <T> SimpleModule addSerializer(Class<? extends T> type, JsonSerializer<T> ser)
From source file:com.example.AuthzApp.java
@Bean
ObjectMapper objectMapper() {/*from ww w. ja v a 2s .c o m*/
final JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(LocalDateTime.class,
new LocalDateTimeSerializer(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
return new Jackson2ObjectMapperBuilder()
.featuresToDisable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).modules(javaTimeModule)
.serializationInclusion(JsonInclude.Include.NON_NULL)
.propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE).build();
}