赞
踩
异常信息:JSON parse error: Cannot deserialize value of type `java.util.Date` from String "2022-12-15 12:28:21": not a valid representation (error: Failed to parse Date value '2022-12-15 12:28:21': Cannot parse date "2022-12-15 12:28:21": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSX', parsing fails (leniency? null)); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "2022-12-15 12:28:21": not a valid representation (error: Failed to parse Date value '2022-12-15 12:28:21': Cannot parse date "2022-12-15 12:28:21": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSX', parsing fails (leniency? null))
在测试过程中发现从其他服务获取的日期数据(字符串类型)无法转为date,最后将注解换为@JsonFormat解决
解决办法:
将@DateTimeFormat(pattern = “yyyy-MM-dd HH-mm-ss”)
换为@JsonFormat( timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。