Java Spring Jackons Date serialization

后端 未结 4 1130
野的像风
野的像风 2021-01-13 00:20

I\'m using Spring MVC and Jackson for JSON de/serialization. But im facing a problem with serializing a date.

By default Jackson serialize a date as an epoch. But i

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-13 01:04

    Solution using Spring 3.1.3 and Jackson 2.1.0 that works for me (based on Ryans answer and Kornys notes with additional change in Java code "SerializationConfig.Feature" -> "SerializationFeature")

    public class DateObjectMapper extends ObjectMapper {
    
    public DateObjectMapper() {
        configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);            
    }
    

    Configuration:

    
        
            
                    
            
        
    
    
    
    

提交回复
热议问题