springboot 全局 Date参数接收 String格式 转换异常报错

JSON parse error: Cannot deserialize value of type `java.util.Date` from String \"2023-03-10 10:00:00\": not a valid representation (error: Failed to parse Date value '2023-03-10 10:00:00': Cannot parse date \"2023-03-10 10:00:00\": 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 \"2023-03-10 10:00:00\": not a valid representation (error: Failed to parse Date value '2023-03-10 10:00:00': Cannot parse date \"2023-03-10 10:00:00\": 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 chain: com.example.springboot.domain.OrderDto[\"createDate\"])
 
 
需要加上配置:
#时区,默认为格林尼治时间,即少8小时,所以我们需要+8
spring.jackson.time-zone=GMT+8
#时间格式转换定义
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
posted @ 2023-03-10 14:19  甜菜波波  阅读(793)  评论(0编辑  收藏  举报