java - fastjson處理日期類型轉(zhuǎn)換各種方法的優(yōu)劣
問(wèn)題描述
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);
求助一下大神在高并發(fā)下在轉(zhuǎn)換的準(zhǔn)確的基礎(chǔ)上,哪個(gè)性能更好一些
問(wèn)題解答
回答1:傳時(shí)間最好是用Unix時(shí)間戳(用秒還是毫秒,兩邊約定好就可以了)。
用yyyy-MM-dd HH:mm:ss的話,碰到兩邊服務(wù)器時(shí)區(qū)不一樣,多半要出問(wèn)題的。
相關(guān)文章:
1. javascript - sublime快鍵鍵問(wèn)題2. javascript - immutable配合react提升性能?3. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽數(shù)據(jù)變化4. javascript - 移動(dòng)端上不能實(shí)現(xiàn)拖拽布局嗎?5. 實(shí)現(xiàn)bing搜索工具urlAPI提交6. javascript - react native在run-android時(shí)出現(xiàn)這個(gè)錯(cuò)誤該怎么解決?大神賜教7. javascript - 如何判斷不同兩個(gè)對(duì)象觸發(fā)同一事件?8. thinkPHP5中獲取數(shù)據(jù)庫(kù)數(shù)據(jù)后默認(rèn)選中下拉框的值,傳遞到后臺(tái)消失不見。有圖有代碼,希望有人幫忙9. javascript - ios返回不執(zhí)行js怎么解決?10. index.php錯(cuò)誤,求指點(diǎn)

網(wǎng)公網(wǎng)安備