java - fastjson处理日期类型转换各种方法的优劣
问题描述
ExpIssue exp = new ExpIssue(); exp.setCreateTime(new Date()); exp.setDealContent('liahodbfoasdhf');第一种: String jstr = JSON.toJSONStringWithDateFormat(exp, 'yyyy-MM-dd HH:mm:ss');第二种: String ste = JSON.toJSONString(exp, SerializerFeature.WriteDateUseDateFormat);第三种:SerializeConfig mapping = new SerializeConfig(); mapping.put(Date.class, new SimpleDateFormatSerializer('yyyy-MM-dd HH:mm:ss')); String json = JSONObject.toJSONString(issue,mapping,SerializerFeature.WriteDateUseDateFormat);
求助一下大神在高并发下在转换的准确的基础上,哪个性能更好一些
问题解答
回答1:传时间最好是用Unix时间戳(用秒还是毫秒,两边约定好就可以了)。
用yyyy-MM-dd HH:mm:ss的话,碰到两边服务器时区不一样,多半要出问题的。
相关文章:
