json转bean,Date格式转化处理(fastJson)

业务:json转成实体类,实体中有Date格式,直接转换报错!!!

报错:

Exception in thread "main" com.alibaba.fastjson.JSONException: For input string: "2018/11/16 3:06:41"

废话不多说,直接上!

json串:

{'id':'181116030522211648','sendtime':'2018/11/16 3:06:41'}

实体字段:

@JSONField(format = "yyyy/MM/dd HH:mm:ss")
    private Date sendtime;

转换:

Hotlinemessage delayresult = JSON.parseObject(json, Hotlinemessage.class);

 

你可能感兴趣的:(JAVA)