feat: LocalDate Foramatter 설정 반영
parent
0e6a08795e
commit
f376877179
@ -0,0 +1,8 @@
|
|||||||
|
package com.xit.biz.ctgy.repository;
|
||||||
|
|
||||||
|
import com.xit.biz.ctgy.entity.MinInfoBoard680;
|
||||||
|
import com.xit.biz.ctgy.entity.Tf680Recall;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface ITf680RecallRepository extends JpaRepository<Tf680Recall, Long> {
|
||||||
|
}
|
@ -1,39 +0,0 @@
|
|||||||
package com.xit.core.config.support;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.format.datetime.DateFormatter;
|
|
||||||
import org.springframework.format.datetime.DateFormatterRegistrar;
|
|
||||||
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
|
||||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
|
||||||
import org.springframework.format.support.FormattingConversionService;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LocalDate / LocalDateTime type 데이타 정제
|
|
||||||
* 2022-03-24T11:30:09.184Z -> 2022-03-24 11:30:09
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class DateTimeConfig extends WebMvcConfigurationSupport {
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Bean
|
|
||||||
@Override
|
|
||||||
public FormattingConversionService mvcConversionService() {
|
|
||||||
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(false);
|
|
||||||
|
|
||||||
DateTimeFormatterRegistrar dateTimeRegistrar = new DateTimeFormatterRegistrar();
|
|
||||||
dateTimeRegistrar.setDateFormatter(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
||||||
dateTimeRegistrar.setDateTimeFormatter(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
dateTimeRegistrar.registerFormatters(conversionService);
|
|
||||||
|
|
||||||
DateFormatterRegistrar dateRegistrar = new DateFormatterRegistrar();
|
|
||||||
dateRegistrar.setFormatter(new DateFormatter("yyyy-MM-dd"));
|
|
||||||
dateRegistrar.registerFormatters(conversionService);
|
|
||||||
|
|
||||||
return conversionService;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.xit.core.config.support;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||||
|
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LocalDate, LocalDateTime 사용을 의한 formatter
|
||||||
|
* Swagger 사용시 WebMvcConfigurationSupport 의 확장이 불가 하여 별도로 등록
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class DateTimeFormatterConfig {
|
||||||
|
private static final String dateFormat = "yyyy-MM-dd";
|
||||||
|
private static final String dateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
|
||||||
|
return builder -> {
|
||||||
|
builder.simpleDateFormat(dateTimeFormat);
|
||||||
|
builder.serializers(new LocalDateSerializer(DateTimeFormatter.ofPattern(dateFormat)));
|
||||||
|
builder.serializers(new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue