jsonobject.tobean date的解决办法

时间:2023-01-18 21:44:36

if(zhongdJsonArr!=null&&zhongdJsonArr.size()>0){
for (int i = 0; i < zhongdJsonArr.size(); i++) {
entry = zhongdJsonArr.getJSONObject(i);
//控制java.util.date
String[] dateFormats = new String[]{"yyyy-MM-dd HH:mm:ss"};
JSONUtils.getMorpherRegistry().registerMorpher(new DateMorpher(dateFormats));


KmGmZhongduaninfo info = (KmGmZhongduaninfo)JSONObject.toBean(entry, KmGmZhongduaninfo.class);

zhongduanService.addOrModifyOrDelZhongduan(info,Integer.parseInt(syncType));
}

jsonObject.put("resCode", 200);
jsonObject.put("resDesc", "处理成功!");

}

关键代码:

//控制java.util.date
String[] dateFormats = new String[]{"yyyy-MM-dd HH:mm:ss"};

JSONUtils.getMorpherRegistry().registerMorpher(new DateMorpher(dateFormats));




感谢http://www.iteye.com/problems/9822提供.