JSON Serializing date in a custom format (Can not construct instance of java.util.Date from String value)

后端 未结 6 1421
野的像风
野的像风 2020-12-03 07:01
could not read JSON: Can not construct instance of java.util.Date from String 
value \'2012-07-21 12:11:12\': not a valid representation(\"yyyy-MM-dd\'T\'HH:mm:ss.SS         


        
6条回答
  •  天命终不由人
    2020-12-03 07:28

    I solved this by using the below steps.

    1.In entity class annote it using @JsonDeserialize

    @Entity
    @Table(name="table")
    public class Table implements Serializable {
    // Some code
    @JsonDeserialize(using= CustomerDateAndTimeDeserialize.class)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="created_ts")
    private Date createdTs
    }
    
    1. Write CustomDateAndTimeDeserialize.java Sample Code

提交回复
热议问题