Force Milliseconds When Serializing Instant to ISO8601 using Jackson

前端 未结 5 600
野的像风
野的像风 2021-01-11 15:01

I have some questions related to JSON serialization using Jackson in a project where I use Spring Boot 2.0.0.M6, Spring Framework 5.0.1.R

5条回答
  •  伪装坚强ぢ
    2021-01-11 15:40

    Rather than fixing the bug of Jackson library, following could be a quick work around: Create a string variable in the POJO class where you have Timestamp variable:

    private Timestamp createTimeStamp;
    
    private String stringCreateTimeStamp;   
    

    capture timestamp value as a string:

    listOfPojo.forEach(pojo-> {
                pojo.setStringCreateTimeStamp(request.getcreateTimeStamp().toString());
            });
    

    Refer https://www.baeldung.com/java-string-to-timestamp for conversions

提交回复
热议问题