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的话,碰到两边服务器时区不一样,多半要出问题的。
相关文章:
1. android自带时钟应用的这个效果是怎么做的2. javascript - 在top.jsp点击退出按钮后,right.jsp进行页面跳转,跳转到login.jsp3. mysql sql where id in(25,12,87) 结果集如何用按照 25 12 87排序?4. javascript - 如何在外部点击,跳转到网页后,显示指定的模块。5. 前端 - 提问关于background-image不显示的问题6. mysql sum去除重复7. 为什么PHP链接sql乱码8. html5 - 如何禁止百度转码?9. 使用未定义的常量user_id-假定为“user_id”10. phpstudy v8打开数据库就出错,而phpstudy 2018不会

网公网安备