框架:spring mvc+mybatils
场景:从Oracle获取到的timestamp数据或者date数据时,
使用 json.add("custName",jsonParser.parse(wholeResult.get("dataDt")));时报jsonparseEction,
此处是因为该处包含有时间格式的数据,jsonParser.parse()不能直接转换,
解决办法:
使用Gson先定义好数据格式再进行编译
Gson gson2=new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
json.add("dataDt",jsonParser.parse(gson2.toJson(wholeResult.get("dataDt"))));