當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
JSONObject.fromObject() 转换时的日期处理问题
生活随笔
收集整理的這篇文章主要介紹了
JSONObject.fromObject() 转换时的日期处理问题
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
JSONObject.fromObject() 轉(zhuǎn)換時(shí)的日期處理問題
;
JSONObject jsonObject=JSONObject.fromObject(object); CarContractEntity carContract=(CarContractEntity)JSONObject.toBean(jsonObject, CarContractEntity.class)object 里的日期類型為 yyyy-MM-dd HH:mm:ss 不能正確被裝進(jìn)CarContractEntity 中,并且會(huì)默認(rèn)賦值當(dāng)前時(shí)間!
以下為正確處理方式:
JSONObject jsonObject=JSONObject.fromObject(params.get("carContract"));JSONUtils.getMorpherRegistry().registerMorpher(new DateMorpher(new String[] {"yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss"}));CarContractEntity carContract=(CarContractEntity)JSONObject.toBean(jsonObject, CarContractEntity.class);總結(jié)
以上是生活随笔為你收集整理的JSONObject.fromObject() 转换时的日期处理问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: EXCEL闪退的处理方法
- 下一篇: JSONObject没有fromObje