json和bean互转中时间格式fastJson(时间总是系统当前时间的处理)

 

 

用fastjson保证前台传过来的json转化成实体时间格式的不会变成当前时间

 

 

 

public String saveWXOrderInfo() throws Exception{

 

//JSONUtils.getMorpherRegistry().registerMorpher( new DateMorpher(new String[] { "yyyy-MM-dd hh:mm:ss" }));

JsonConfig jsonConfig = new JsonConfig();

jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());

logger.info("保存订单==============开始json==="+jsonsWxInFo);

JSONObject jb=JSONObject.fromObject(jsonsWxInFo,jsonConfig);

//JSONObject jbb=(JSONObject)jb.get("result");

//JSONObject jbcareerInfo=(JSONObject)jbb.get("careerInfo");

//logger.info("保存订单==============开始json  jb==="+jbcareerInfo.get("jobEntryTime"));

String[] dateFormats = new String[] {"yyyy-MM-dd HH:mm:ss"};

 

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

TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));

QueryOrderDetailReq qp = com.alibaba.fastjson.JSONObject.parseObject(jsonsWxInFo, QueryOrderDetailReq.class);

//QueryOrderDetailReqqp=(QueryOrderDetailReq)JSONObject.toBean(jb,QueryOrderDetailReq.class);

logger.info("保存订单==============开始wcareerInfo==="+qp.getResult().getCareerInfo());

 

}

你可能感兴趣的:(json)