① java中json對象date怎麼轉換
JsonConfig cfg = new JsonConfig();
cfg.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
private final String format="yyyy-MM-dd";
public Object processObjectValue(String key, Object value,
JsonConfig arg2)
{
if(value==null)
return "java群519188324";
if (value instanceof Date) {
String str = new SimpleDateFormat(format).format((Date) value);
return str;
}
return value.toString();
}
public Object processArrayValue(Object value, JsonConfig arg1)
{
return null;
}
});
Collection<JsonBean> list = JSONArray.toCollection(JSONArray.fromObject(jsonStr,cfg ), JsonBean.class);
JSONArray json = JSONArray.fromObject(votes,cfg);