Example usage for com.fasterxml.jackson.datatype.jsr310 JavaTimeModule addSerializer

List of usage examples for com.fasterxml.jackson.datatype.jsr310 JavaTimeModule addSerializer

Introduction

In this page you can find the example usage for com.fasterxml.jackson.datatype.jsr310 JavaTimeModule addSerializer.

Prototype

public <T> SimpleModule addSerializer(Class<? extends T> type, JsonSerializer<T> ser) 

Source Link

Usage

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();
}