Cannot parse date “2020-08-31 00:00:00“: while it seems to fit format ‘yyyy-MM-dd‘T‘HH:mm:ss.SSS

cby1516發表於2020-12-29

報錯內容

Cannot parse date "2020-08-31 00:00:00": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSS

報錯原因

這種格式springboot中不能識別並轉化。它會丟擲異常資訊,提示轉換失敗

解決方法

    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiParam(value = "有效期開始日期")
    private Date queryStartDate;

    @JsonFormat(shape= JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiParam(value = "有效期結束日期")
    private Date queryEndDate;

 

相關文章