Can not deserialize value of type java.util.Date from String "2020-01-10 16:18:12": not a valid rep

Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.util.Date from String "2020-01-10 16:18:12": not a valid representation (error: Failed to parse Date value '2020-01-10 16:18:12': Can not parse date "2020-01-10 16:18:12Z": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z'', parsing fails (leniency? null))
 at [Source: java.io.PushbackInputStream@3a01026e; line: 1, column: 61] (through reference chain: com.yaoling.cms.form.ArticlesForm["createTime"])
    at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:74) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1410) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:926) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate(StdDeserializer.java:819) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate(StdDeserializer.java:788) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateBasedDeserializer._parseDate(DateDeserializers.java:172) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateDeserializer.deserialize(DateDeserializers.java:259) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateDeserializer.deserialize(DateDeserializers.java:242) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:357) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:148) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798) ~[jackson-databind-2.8.8.jar:2.8.8]
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2922) ~[jackson-databind-2.8.8.jar:2.8.8]
    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:231) ~[spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE]
    ... 95 common frames omitted
 

往mangodb插数据的时候报错了。

我给一个时间createTime传值  2020-01-10 16:18:12 

然后控制台就报错了

报错内容如上,其中有一句很重要:

error: Failed to parse Date value '2020-01-10 16:18:12': 
Can not parse date "2020-01-10 16:18:12Z": 
while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z''

报错提示说要yyyy-MM-dd'T'HH:mm:ss.SSS'Z' 格式的时间数据,也就是应该传UTC日期格式的数据(例如2020-01-10T16:18:12.000Z),或者直接传时间戳(例如1578645361488)也行

 

你可能感兴趣的:(Can not deserialize value of type java.util.Date from String "2020-01-10 16:18:12": not a valid rep)