解決Springboot中的日期解析錯誤


錯誤信息:

error: Failed to parse Date value '2022-01-12 15:00:00': Cannot parse date "2022-01-12 15:00:00": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null)

解決辦法:

使用fastJson,在日期屬性上添加 org.springframework.format.annotation.DateTimeFormat ---> @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")

com.fasterxml.jackson.annotation.JsonFormat ---> @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM