当前位置:   article > 正文

JSON parse error: Cannot deserialize value of type `java.util.Date` from String “2022-12-15 12:28:21

json parse error: cannot deserialize value of type `java.lang.string` from o

异常信息: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")

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/739465
推荐阅读
相关标签
  

闽ICP备14008679号