Write in front:
The page sends the AJAX request to the background, returns the corresponding JSON format data to the foreground page for data presentation, and if the JSON data contains a datetime, the date must be processed
The following is the relevant Code section
Jsonconfig jsonconfig=New jsonconfig (); Jsonconfig.registerjsonvalueprocessor (Date. class,new jsondatevalueprocessor ()= Jsonarray.fromobject (list2,jsonconfig);
There is a need to implement Jsonvalueprocessor
Public classJsondatevalueprocessorImplementsJsonvalueprocessor {//Date Format PrivateString format = "Yyyy-mm-dd HH:mm:ss"; Publicjsondatevalueprocessor () {} Publicjsondatevalueprocessor (String format) { This. Format =format; } @Override PublicObject Processarrayvalue (Object o, Jsonconfig jsonconfig) {returnprocess (o); } @Override PublicObject Processobjectvalue (String s, Object O, Jsonconfig jsonconfig) {returnprocess (o); } PrivateObject Process (object value) {if(ValueinstanceofDate) {SimpleDateFormat SDF=Newsimpledateformat (format, locale.uk); returnSdf.format (value); } returnValue = =NULL? "": Value.tostring (); }}
Did not use the other usage, also did not go too much to dig, just make a record ~ ~ ~
Jsonconfig Processing Date Time