public class Jsondatevalueprocessor implements Jsonvalueprocessor {
Private String format = "YYYYMMDD";
Public Jsondatevalueprocessor () {
Super ();
}
Public jsondatevalueprocessor (String format) {
Super ();
This.format = format;
}
@Override
public Object Processarrayvalue (object Paramobject,
Jsonconfig paramjsonconfig) {
return process (Paramobject);
}
@Override
public Object Processobjectvalue (String paramstring, Object Paramobject,
Jsonconfig paramjsonconfig) {
return process (Paramobject);
}
Private object Process (object value) {
if (value instanceof Date) {
SimpleDateFormat SDF = new SimpleDateFormat (format, Locale.china);
return Sdf.format (value);
}
return value = = null? "": value.tostring ();
}
}
That's what the controller says.
list<t> list = Service.queryfromwtxs (); Query to the Entity class table to display
Jsonconfig jsonconfig = new Jsonconfig ();
Jsonconfig.registerjsonvalueprocessor (Date.class, New Jsondatevalueprocessor ());
Jsonarray Jsonarray22=jsonarray.fromobject (list,jsonconfig); The Entity class table turns into JSON; time format in time-to-variable converters
sum = List.size ();
Mv.addobject ("list", jsonArray22); Use "List" in JSP
Time format time to JSON is changed to normal string time 20170519