- 日常的用法
JSON.toJSONString(Object);
平时一直这么用,完全没问题,突然发现日期突然变成了时间戳,才回头找了api,使用了如下方法处理。 - 防止日期变时间戳
JSON.toJSONStringWithDateFormat(Object,dateformat,SerializerFeature.WriteDateUseDateFormat)
eg:其中dateformat为日期格式,根据需要自定义如(yyyy-MM-dd)
JSON.toJSONString(Object);
JSON.toJSONStringWithDateFormat(Object,dateformat,SerializerFeature.WriteDateUseDateFormat)
eg:其中dateformat为日期格式,根据需要自定义如(yyyy-MM-dd)
本文标题:java对象转换json字符串防止日期类型变时间戳
本文链接:https://www.haomeiwen.com/subject/cfxxnctx.html
网友评论