java - 转换json格式时间乱码问题
伊谢尔伦
伊谢尔伦 2017-04-18 10:26:14
0
2
655

http://img.mukewang.com/58468...

private static String dateFormat;
private static SerializeConfig mapping = new SerializeConfig();
static {
    dateFormat = "yyyy-MM-dd HH:mm:ss";
    mapping.put(Date.class, new SimpleDateFormatSerializer(dateFormat));
}
String jsonString = JSONObject.toJSONString(deal,mapping,SerializerFeature.WriteDateUseDateFormat);

这个方法是把jsonString放入redis中,但有两个方法同时放一个redis中,这两个方法的deal实体类中的属性还不相同,其他代码都一样,不知道是不是这个问题,希望有大神给解释一下

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
黄舟

It seems that the thread of SimpleDateFormat is not safe, and multi-thread concurrency will cause this

Peter_Zhu

It doesn’t feel necessary to be so complicated, it’s very simple to use fastjson

        Map<String, Object> map = new HashMap<>();
        map.put("createTime", new Date());
        map.put("name", "simeon");
        String jstr = JSON.toJSONStringWithDateFormat(map, "yyyy-MM-dd HH:mm:ss");
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!