日期:2014-05-16 浏览次数:20448 次
JSONObject json = JSONObject.fromObject(str); JSONUtils.getMorpherRegistry().registerMorpher(new DateMorpher(new String[]{"yyyy-MM-dd HH:mm:ss"})); App app = (App) json.toBean(json, App.class); System.out.println(app.getCreateTime());
JsonConfig config = new JsonConfig(); config.registerJsonValueProcessor(Date.class, new JsonValueProcessor() { private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Override public Object processObjectValue(String key, Object value, JsonConfig cfg) { return format.format((Date)value); } @Override public Object processArrayValue(Object value, JsonConfig cfg) { return format.format((Date)value); } });