java - fastjson處理日期類型轉(zhuǎn)換各種方法的優(yōu)劣
問題描述
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è)性能更好一些
問題解答
回答1:傳時(shí)間最好是用Unix時(shí)間戳(用秒還是毫秒,兩邊約定好就可以了)。
用yyyy-MM-dd HH:mm:ss的話,碰到兩邊服務(wù)器時(shí)區(qū)不一樣,多半要出問題的。
相關(guān)文章:
1. mysql - 請問數(shù)據(jù)庫字段為年月日,傳進(jìn)的參數(shù)為月,怎么查詢那個(gè)月所對應(yīng)的數(shù)據(jù)2. node.js - win 下 npm install 遇到了如下錯(cuò)誤 會(huì)導(dǎo)致 無法 run dev么?3. javascript - js判斷一個(gè)數(shù)組是否重復(fù)4. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時(shí)間會(huì)消失是什么情況?5. [python2]local variable referenced before assignment問題6. Python2中code.co_kwonlyargcount的等效寫法7. html - 移動(dòng)端radio無法選中8. php - 微信開發(fā)驗(yàn)證服務(wù)器有效性9. javascript - vue+iview upload傳參失敗 跨域問題后臺已經(jīng)解決 仍然報(bào)403,這是怎么回事啊?10. mysql - 如何在有自增id的情況下,讓其他某些字段能不重復(fù)插入
