我是靠谱客的博主 无语人生,这篇文章主要介绍JSON parse error: Cannot deserialize value of type `java.util.Date` from String “2022-06-20T12:26:06,现在分享给大家,希望可以做个参考。

在feign调用的过程中(返回一个实体类),遇到了一个错误,关于解析日期格式的:

Caused by: org.springframework.web.client.RestClientException: Error while extracting response for type [class com.cjw.order.entity.UserMemberDTO] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.Date` from String "2022-06-20T12:26:06.000+0000": not a valid representation (error: Failed to parse Date value '2022-06-20T12:26:06.000+0000': Unparseable date: "2022-06-20T12:26:06.000+0000"); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "2022-06-20T12:26:06.000+0000": not a valid representation (error: Failed to parse Date value '2022-06-20T12:26:06.000+0000': Unparseable date: "2022-06-20T12:26:06.000+0000")
 at [Source: (PushbackInputStream); line: 1, column: 545] (through reference chain: com.cjw.order.entity.UserMemberDTO["gmtCreate"])
	at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:119)
	at org.springframework.cloud.openfeign.support.SpringDecoder.decode(SpringDecoder.java:59)
	at org.springframework.cloud.openfeign.support.ResponseEntityDecoder.decode(ResponseEntityDecoder.java:62)
	at feign.optionals.OptionalDecoder.decode(OptionalDecoder.java:36)
	at feign.SynchronousMethodHandler.decode(SynchronousMethodHandler.java:178)
	... 60 more

解决办法,加个注解

@JsonFormat(pattern="yyyy-MM-dd")
private Date gmtCreate;

最后

以上就是无语人生最近收集整理的关于JSON parse error: Cannot deserialize value of type `java.util.Date` from String “2022-06-20T12:26:06的全部内容,更多相关JSON内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(105)

评论列表共有 0 条评论

立即
投稿
返回
顶部