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. html - vue項目中用到了elementUI問題2. 對mysql某個字段監控的功能3. javascript - windows下如何使用babel,遇到了困惑4. javascript - js中向下取整5. JavaScript事件6. showpassword里的this 是什么意思?代表哪個元素7. java - input file類型上傳了一個文件,想計算一下上傳文件的大小?8. java - Spring MVC怎么實現提交表單后跳轉?9. python - 為什么正常輸出中文沒有亂碼,zip函數之后出現中文編程unicode編碼的問題,我是遍歷輸出的啊。10. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能
