Cannot deserialize value of type `java.util.Date` from String \“2022-05-12 09:53:08\“: not a valid

JSON parse error: Cannot deserialize value of type java.util.Date from String “2022-05-12 09:53:08”: not a valid representation (error: Failed to parse Date value ‘2022-05-12 09:53:08’: Cannot parse date “2022-05-12 09:53:08”: while it seems to fit format ‘yyyy-MM-dd’T’HH:mm:ss.SSSZ’, parsing fails (leniency? null)); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.util.Date from String “2022-05-12 09:53:08”: not a valid representation (error: Failed to parse Date value ‘2022-05-12 09:53:08’: Cannot parse date “2022-05-12 09:53:08”: while it seems to fit format ‘yyyy-MM-dd’T’HH:mm:ss.SSSZ’, parsing fails (leniency? null))\n at [Source: (PushbackInputStream); line: 3, column: 18] (through reference

解决办法:在实体类dto 字段上面加上这2个注解即可
@DateTimeFormat(pattern = “yyyy-MM-dd HH:mm:ss”)
@JsonFormat(timezone = “GMT+8”, pattern = “yyyy-MM-dd HH:mm:ss”)

你可能感兴趣的:(java,开发语言)