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