java - JSP - How do get time to constantly update by ms -


I'm trying to write an example JSP page for myself (very new JSP), and an example to write one , But how do I get time to update constantly?

Here's my snippet of code:

  & lt; Body & gt; & Lt;% java.text.DateFormat df = new java.text.SimpleDateFormat ("HH: mm: SS: SS z MM / dd / yyyy"); Calendar cal = calendar.justinstance (); & Gt%; & Lt; H1 & gt; Current date and time: & lt;% = df.format (cal.getTime ())% & gt; & Lt; / H1> & Lt; / Body & gt;   

The way I am using a tomcat server to deploy it

  Function UpdateAirtime () {var now = new date (), months = ['Jan', 'Feb', '...']; Time = now.getHours () + ':' + now.getMinutes (), date = [now.getDate (), months [now.getMonth ()], now.Guoufure ()]. Join (''); Document.getElementById ('Current Time'). InnerHTML = [date, time] .join ('/'); SetTimeout (updateYourTime, 1000); // This method will call for every other} updateYourTime (); // Initial call   

For details

  & lt; Div id = "currentTime" & gt; & Lt; / Time & gt;    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -