【7.2.5】【convert】更新日期格式转化写法

pull/37/head
fengshuonan 2022-09-25 10:50:14 +08:00
parent 5638037e8d
commit 2f0e2989e7
1 changed files with 24 additions and 4 deletions

View File

@ -53,7 +53,12 @@ public class GunsDateConvertAutoConfiguration {
*/
@Bean
public Converter<String, LocalDate> localDateConverter() {
return source -> LocalDate.parse(source, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
return new Converter<String, LocalDate>() {
@Override
public LocalDate convert(String source) {
return LocalDate.parse(source, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
}
};
}
/**
@ -64,7 +69,12 @@ public class GunsDateConvertAutoConfiguration {
*/
@Bean
public Converter<String, LocalDateTime> localDateTimeConverter() {
return source -> LocalDateTime.parse(source, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
return new Converter<String, LocalDateTime>() {
@Override
public LocalDateTime convert(String source) {
return LocalDateTime.parse(source, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
}
};
}
/**
@ -75,7 +85,12 @@ public class GunsDateConvertAutoConfiguration {
*/
@Bean
public Converter<String, LocalTime> localTimeConverter() {
return source -> LocalTime.parse(source, DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN));
return new Converter<String, LocalTime>() {
@Override
public LocalTime convert(String source) {
return LocalTime.parse(source, DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN));
}
};
}
/**
@ -86,7 +101,12 @@ public class GunsDateConvertAutoConfiguration {
*/
@Bean
public Converter<String, Date> dateConverter() {
return source -> DateUtil.parse(source.trim());
return new Converter<String, Date>() {
@Override
public Date convert(String source) {
return DateUtil.parse(source.trim());
}
};
}
}