Stringutil. Java
Package COM. LH. bean; import Java. text. simpledateformat; import Java. util. calendar; import Java. util. date; public class stringutil {// Date string private string timestr1; private string timestr2; // use the Calendar Object method Public String gettimestr1 () {// create the Calendar Object calendar c = calendar. getinstance (); // get the year, month, and day of the current time int year = C. get (C. year); int month = C. get (C. month) + 1; int day = C. get (C. day_of_month); int hour = C. get (C. hour_of_day); int minute = C. get (C. minute); int second = C. get (C. second); timestr1 = year + "-" + month + "-" + day + "-" + hour + ":" + minute + ":" + second; return timestr1;} // obtain the current time of the system using the date object Public String gettimestr2 () {// create a date object that represents the current time date = new date (); // create the format Date and Time object simpledateformat format = new simpledateformat ("yyyy-mm-dd hh: mm: SS"); timestr2 = format. format (date); Return timestr2 ;}}
Index. jsp
<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" UTF-8 "%> <HTML>