fastjson对象转为json字符串日期格式变为时间戳问题

将map集合转为json对象时遇到一个问题,map中的value为日期格式如"2019-03-01",在使用 JSONObject.toJSON(map).toString() 转换后的value变成了时间戳,显示出来很不友好。

fastjson的API中有个方法可以将对象中的时间格式不转化为时间戳的方法:

JSON.toJSONStringWithDateFormat(Object,dateformat,SerializerFeature.WriteDateUseDateFormat)

例如

JSON.toJSONStringWithDateFormat(map, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat);
原文地址:https://www.cnblogs.com/niudaben/p/13229970.html