Example usage for com.fasterxml.jackson.datatype.jsr310.ser LocalDateTimeSerializer LocalDateTimeSerializer

List of usage examples for com.fasterxml.jackson.datatype.jsr310.ser LocalDateTimeSerializer LocalDateTimeSerializer

Introduction

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

Prototype

public LocalDateTimeSerializer(DateTimeFormatter f) 

Source Link

Usage

From source file:com.example.AuthzApp.java

@Bean
ObjectMapper objectMapper() {/*from w ww  .jav a2s  .com*/
    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();
}

From source file:com.example.ResourceConfig.java

@Bean
Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
    return new Jackson2ObjectMapperBuilder().propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
            .featuresToDisable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
            .modules(new JavaTimeModule().addSerializer(LocalDateTime.class,
                    new LocalDateTimeSerializer(DateTimeFormatter.ISO_LOCAL_DATE_TIME)));
}