How to get the current date and time in the JSP page
<SCRIPT LANGUAGE="JavaScript"> var myDate = new Date(); myDate.getYear(); // Get the current year (2 Bit ) myDate.getFullYear(); // Get the full year (4 Bit ,1970-????) myDate.getMonth(); // Get the current month (0-11,0 Representative 1 Month ) myDate.getDate(); // Get the current day (1-31) myDate.getDay(); // Get the current week X(0-6,0 On behalf of Sunday ) myDate.getTime(); // Get the current time ( From 1970.1.1 Beginning milliseconds ) myDate.getHours(); // Get the current number of hours (0-23) myDate.getMinutes(); // Get the current number of minutes (0-59) myDate.getSeconds(); // Gets the current number of seconds (0-59) myDate.getMilliseconds(); // Gets the current number of milliseconds (0-999) myDate.toLocaleDateString(); // Get the current date var mytime=myDate.toLocaleTimeString(); // Get the current time myDate.toLocaleString( ); // Get the date and timeif (mytime<"23:30:00"){alert(mytime);}</SCRIPT>
<%java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");java.util.Date currentTime = new java.util.Date();// Get the current system timeString str_date1 = formatter.format(currentTime); // Formatting Date TimeString str_date2 = currentTime.toString(); // Will Date Type date and time to string form%>