栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

JSON parse error: Cannot deserialize value of type `java.util.Date` from String “2022-06-20T12:26:06

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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;
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/988839.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号