通用解决LocalDateTime转为字符串后中间含“T”

原文链接: https://juejin.im/post/5ceb4f156fb9a07f06554b63
@Configuration
public class LocalDateTimeSerializerConfig {

    @org.springframework.beans.factory.annotation.Value("${spring.jackson.date-format:yyyy-MM-dd HH:mm:ss}")
    private String pattern;

    @Bean
    public LocalDateTimeSerializer localDateTimeDeserializer() {
        return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(pattern));
    }

    @Bean
    public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
        return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeDeserializer());
    }
}
复制代码

转载于:https://juejin.im/post/5ceb4f156fb9a07f06554b63

你可能感兴趣的:(通用解决LocalDateTime转为字符串后中间含“T”)