Jsonconfig Processing Date Time

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.