Cannot parse date while it seems to fit format ‘yyyy-MM-dd‘T‘HH:mm:ss.SSSZ‘

简介: Cannot parse date while it seems to fit format ‘yyyy-MM-dd‘T‘HH:mm:ss.SSSZ‘
{
    "timestamp": "2020-12-10T02:46:12.291+0000",
    "status": 400,
    "error": "Bad Request",
    "message": "JSON parse error: Cannot deserialize value of type `java.util.Date` from String \"2000-01-01 00:00:00\": not a valid representation (error: Failed to parse Date value '2000-01-01 00:00:00': Cannot parse date \"2000-01-01 00: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 \"2000-01-01 00:00:00\": not a valid representation (error: Failed to parse Date value '2000-01-01 00:00:00': Cannot parse date \"2000-01-01 00: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: 4, column: 19] (through reference chain: com.liupei.entity.Admin[\"createDate\"])",
    "path": "/admin/save"
}

提交数据出现:

{

   "timestamp": "2020-12-10T02:46:12.291+0000",

   "status": 400,

   "error": "Bad Request",

   "message": "JSON parse error: Cannot deserialize value of type `java.util.Date` from String \"2000-01-01 00:00:00\": not a valid representation (error: Failed to parse Date value '2000-01-01 00:00:00': Cannot parse date \"2000-01-01 00: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 \"2000-01-01 00:00:00\": not a valid representation (error: Failed to parse Date value '2000-01-01 00:00:00': Cannot parse date \"2000-01-01 00: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: 4, column: 19] (through reference chain: com.liupei.entity.Admin[\"createDate\"])",

   "path": "/admin/save"

}

 

解决:

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDate;
相关文章
2021-10-10T16:00:00.000Z: expected format yyyy-MM-dd HH:mm:ss 时间戳格式化
2021-10-10T16:00:00.000Z: expected format yyyy-MM-dd HH:mm:ss 时间戳格式化
168 0
|
7月前
yyyy-MM-dd'T'HH:mm:ss.SSSZZ和yyyy-MM-dd'T'HH:mm:ss.SSSXXX之间的区别
【5月更文挑战第7天】yyyy-MM-dd'T'HH:mm:ss.SSSZZ和yyyy-MM-dd'T'HH:mm:ss.SSSXXX之间的区别
329 0
|
JavaScript 前端开发
【JS】获取当前时间,且格式为yyyy-MM-dd hh:mm:ss
【JS】获取当前时间,且格式为yyyy-MM-dd hh:mm:ss
219 0
|
7月前
joda time将10位或者13位时间戳转为标准日期格式: yyyy-MM-dd HH:mm:ss
joda time将10位或者13位时间戳转为标准日期格式: yyyy-MM-dd HH:mm:ss
108 0
yyyy-MM-dd和YYYY-MM-dd不是一样的吗?
最近的一个项目中遇到了一个非常有趣的bug,原来yyyy-MM-dd和YYYY-MM-dd是有差异的,具体有什么不同呢?
|
JavaScript 前端开发 数据库
如何将当前时间为:Sun Jan 08 16:47:00 CST 2023格式转换成“yyyy-MM-dd HH:mm:ss“
如何将当前时间为:Sun Jan 08 16:47:00 CST 2023格式转换成“yyyy-MM-dd HH:mm:ss“
203 0
|
NoSQL Java Redis
别再踩坑, yyyy-MM-dd和YYYY-MM-dd格式化日期的区别你知道吗?
别再踩坑, yyyy-MM-dd和YYYY-MM-dd格式化日期的区别你知道吗?
508 0
别再踩坑, yyyy-MM-dd和YYYY-MM-dd格式化日期的区别你知道吗?
|
Java
Java时间格式转换yyyyMMddHHmmss--yyyy-MM-dd HH:mm:ss
Java时间格式转换yyyyMMddHHmmss--yyyy-MM-dd HH:mm:ss
227 0
|
Java
LocalDateTime序列化成yyyy-MM-dd HH:mm
LocalDateTime序列化成yyyy-MM-dd HH:mm
246 0
T16:00:00.000Z: expected format yyyy-MM-dd HH:mm:ss 时间戳格式化
T16:00:00.000Z: expected format yyyy-MM-dd HH:mm:ss 时间戳格式化
1335 0