Time transfer between Java and JavaScript

Source: Internet
Author: User

1. From JavaScript to Java

Js:

    functionquery () {varstartdate=$ ("#startDate"). Text ();//2015-09-30          varenddate=$ ("#endDate"). text (); if(startdate<=enddate) {//Time Legal$.ajax ({type:"POST", DataType:"Text", URL:"Paymonthget.action", data: {"Startmonthstr": startdate+ "00:00:00", "Endmonthstr": enddate+ "00:00:00"}, Success:function(msg) {}, Error:function(data) {alert ("Error");          }            }); }          Else{alert (The end time must be greater than the start time! "); }      }//Query

Java:

New
Startmonth=timestamp.valueof (startmonthstr);//startmonthstr parameters passed in for request

2. From Java to JavaScript

Java:

Jsonarray jsonarray=New  Jsonarray ();                 for (Paymonth ut:list) {                    jsonobject json=new  jsonobject ();                    Json.put ("Date", Ut.getpaydate (). toString ());//Convert to String                    json.put ("pay", ut.getpayfinal ());                    Jsonarray.add (JSON);                }    

Javascript:

var date=New date (data[i-1].date);//data for the coming Jsonarray

You can then refer to the W3school-javascript Date object.

Time transfer between Java and JavaScript

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.