码迷,mamicode.com
首页 > Web开发 > 详细

实际开发中String转换为json串作为入参发生"JSON parse error:Cannot deserialize value of type Date......not a valid解决

时间:2021-01-22 12:29:29      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:字符   alc   status   can   too   entity   sea   ann   inpu   

实际开发中,String拼接成json串作为入参请求接口,发生以下错误

{
    "timestamp": "2018-11-09 14:55:49",
    "status": 400,
    "error": "Bad Request",
    "message": "JSON parse error: Cannot deserialize value of type `java.util.Date` from String \"2016-02-02\": not a valid representation 
    (error: Failed to parse Date value ‘2016-02-02‘: Unparseable date: \"2016-02-02\"); 
    nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: 
    Cannot deserialize value of type `java.util.Date` from String \"2016-02-02\": not a valid representation 
    (error: Failed to parse Date value ‘2016-02-02‘: Unparseable date: \"2016-02-02\")\n at [Source: (PushbackInputStream); 
    line: 89, column: 23] (through reference chain: com.guorenpcic.grecar.dto.vo.Proposal[\"bc\"]->com.guorenpcic.grecar.dto.vo.BCVo[\"prpTitemCar\"]->
    com.×××.grecar.dto.entity.Prptitemcar[\"certifiCateDate\"])",
    "path": "/ecar/calculationPremium"
}

【问题】这是该字符串certifiCateDate作为Date格式的无法转换成json,转换错误。

【解决办法】实体Prptitemcar字段certifiCateDate上添加 @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") 注解既解决。

 

 
 转自: https://blog.csdn.net/qq_30546099/article/details/84644636?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.control

实际开发中String转换为json串作为入参发生"JSON parse error:Cannot deserialize value of type Date......not a valid解决

标签:字符   alc   status   can   too   entity   sea   ann   inpu   

原文地址:https://www.cnblogs.com/javalinux/p/14311824.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!