当前位置: 代码迷 >> 综合 >> Invalid JSON input: Cannot deserialize value of type `java.util.Date` from String “2020-07-05T16:00:
  详细解决方案

Invalid JSON input: Cannot deserialize value of type `java.util.Date` from String “2020-07-05T16:00:

热度:5   发布时间:2024-01-28 02:26:46.0

(spring boot + vue)

1、新增-选择日期-点击保存-报错:报错信息

"Invalid JSON input: Cannot deserialize value of type `java.util.Date` from String "2020-07-05T16:00:00.000Z": not a valid representation (error: Failed to parse Date value '2020-07-05T16:00:00.000Z': Unparseable date: "2020-07-05T16:00:00.000Z"); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "2020-07-05T16:00:00.000Z": not a valid representation (error: Failed to parse Date value '2020-07-05T16:00:00.000Z': Unparseable date: "2020-07-05T16:00:00.000Z")? at [Source: (PushbackInputStream); line: 1, column: 445] (through reference chain: com.senyint.hip.saas.base.model.uc.Organization["licenseStartDate"])"

 

2、解决方案

找到报错的后台实体类,在对应的日期类型上面,加一条注解,即可解决

 @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")