|
|
@@ -0,0 +1,34 @@ |
|
|
|
package com.ningdatech.pmapi.common.config; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; |
|
|
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; |
|
|
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author liuxinxin |
|
|
|
* @date 2023/3/9 下午1:50 |
|
|
|
*/ |
|
|
|
@Configuration |
|
|
|
public class JacksonConfig { |
|
|
|
@Value("${spring.jackson.local-date-time-format:yyyy-MM-dd HH:mm:ss}") |
|
|
|
String localDateTimeFormat; |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
public ObjectMapper objectMapper() { |
|
|
|
ObjectMapper om = new ObjectMapper(); |
|
|
|
JavaTimeModule javaTimeModule = new JavaTimeModule(); |
|
|
|
javaTimeModule.addSerializer(LocalDateTime.class, |
|
|
|
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(localDateTimeFormat))); |
|
|
|
javaTimeModule.addDeserializer(LocalDateTime.class, |
|
|
|
new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(localDateTimeFormat))); |
|
|
|
return om; |
|
|
|
} |
|
|
|
} |