Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var xmlhttp;
- if (window.XMLHttpRequest)
- {
- xmlhttp=new XMLHttpRequest();
- }
- else
- {
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.open('GET','ServletTime.do',false);
- xmlhttp.send();
- alert(xmlhttp.responseText);
- @Jpf.Action(forwards = {
- @Jpf.Forward(name="success", path="ServletTime.do")
- })
- public Forward ServletTime()
- {
- return new Forward(new ServletTime().getTime(this.getRequest(),this.getResponse()));
- }
- public class ServletTime {
- public String getTime(HttpServletRequest request,
- HttpServletResponse response) {
- Calendar calendar = Calendar.getInstance();
- int hh = calendar.get(Calendar.HOUR_OF_DAY);
- int hhZoneOffset = calendar.get(Calendar.ZONE_OFFSET) / ( 60 * 60 * 1000);
- int dstHhOffset = calendar.get(Calendar.DST_OFFSET) / ( 60 * 60 * 1000);
- int gmtHh = hhZoneOffset + dstHhOffset;
- hh = hh - gmtHh;
- int mm = calendar.get(Calendar.MINUTE);
- int ss = calendar.get(Calendar.SECOND);
- int day = calendar.get(Calendar.DAY_OF_MONTH);
- int i_month = calendar.get(Calendar.MONTH);
- int year = calendar.get(Calendar.YEAR);
- String[] monthsYear = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
- String month = monthsYear[i_month];
- String dateServer = day + "/" + month + "/"+ year +" " +(hh>10?hh:("0"+hh)) + ":"+ (mm>10?mm:("0"+mm)) + ":" + (ss>10?ss:("0"+ss));
- request.setAttribute("timestamp", dateServer);
- return dateServer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement