content: package com.homihq.db2rest.config;
  
  import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
  import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
  import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
  import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
  import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
  import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
  import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  
  import java.time.format.DateTimeFormatter;
  
  @Configuration
  @ConditionalOnProperty(prefix = "db2rest.dateTime", name = "enableDataTimeFormatting", havingValue = "true")
  public class DateTimeConfiguration {
  
      @Bean
      public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer(Db2RestConfigProperties db2RestConfigProperties) {
          String timeFormat = db2RestConfigProperties.getDateTime().timeFormat;
          String dateFormat = db2RestConfigProperties.getDateTime().dateFormat;
          String dateTimeFormat = db2RestConfigProperties.getDateTime().dateTimeFormat;
  
          return builder -> {
              builder.simpleDateFormat(dateTimeFormat);
              builder.serializers(new LocalDateSerializer(DateTimeFormatter.ofPattern(dateFormat)));
              builder.serializers(new LocalTimeSerializer(DateTimeFormatter.ofPattern(timeFormat)));
              builder.serializers(new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)));
  
              builder.deserializers(new LocalDateDeserializer(DateTimeFormatter.ofPattern(dateFormat)));
              builder.deserializers(new LocalTimeDeserializer(DateTimeFormatter.ofPattern(timeFormat)));
              builder.deserializers(new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(dateTimeFormat)));
  
          };
      }
  }
  