[Handy record] Time format conversion error: while it seems to fit format 'yyyy-MM-dd'T'HH: mm: ss.SSSZ'

When the microservice consumer calls the provider to obtain entity class data, an error is reported:

java.lang.IllegalArgumentException: Cannot deserialize value of type `java.util.Date` from String "2020-03-17 20:33:37": not a valid representation (error: Failed to parse Date value '2020-03-17 20:33:37': Cannot parse date "2020-03-17 20:33:37": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null))
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: ...)

The general meaning is that the time format does not meet the requirements. Checked the document for time. The default conversion format is

"yyyy-MM-dd'T'HH:mm:ss.SSSZ"  
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"  
"EEE, dd MMM yyyy HH:mm:ss zzz"  
"yyyy-MM-dd" 

Does not meet our requirements, in general, annotate the entity class that needs to be converted

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

Or the microservice configuration center can configure the project uniformly

#spring.jackson.time-zone=GMT+8
#spring.jackson.date-format=yyyy-MM-dd HH:mm:ss

It can be solved!

But recently when using the domestic database highgo adaptation, because of special requirements, the fields are defined in pinyin, such as CJSJ (creation time) At this time, the time field is annotated or the error is reported.The time format is wrong!

Finally, the test found that changing the field to lowercase can solve cjsj (similar to this!)

 

Guess you like

Origin www.cnblogs.com/whaleX/p/12695536.html