jsp中怎么得到当前时间?
来源: 互联网 发布时间:2015-04-02
本文导语: 服务器时间,本地时间也行 | Calendar rightNow = Calendar.getInstance(); out.println(rightNow.getTime()); | 没搞懂你到底要什么,全都给你: Calendar now = new GregorianCalendar(); System.out.println...
服务器时间,本地时间也行
|
Calendar rightNow = Calendar.getInstance();
out.println(rightNow.getTime());
out.println(rightNow.getTime());
|
没搞懂你到底要什么,全都给你:
Calendar now = new GregorianCalendar();
System.out.println(now.get(Calendar.YEAR)); //year
System.out.println(now.get(Calendar.MONTH) + 1);//month
System.out.println(now.get(Calendar.DAY_OF_MONTH)); //day
System.out.println(now.get(Calendar.HOUR_OF_DAY)); //hour
System.out.println(now.get(Calendar.MINUTE)); //minute
System.out.println(now.get(Calendar.SECOND)); //second
System.out.println(now.get(Calendar.MILLISECOND)); //ms
Calendar now = new GregorianCalendar();
System.out.println(now.get(Calendar.YEAR)); //year
System.out.println(now.get(Calendar.MONTH) + 1);//month
System.out.println(now.get(Calendar.DAY_OF_MONTH)); //day
System.out.println(now.get(Calendar.HOUR_OF_DAY)); //hour
System.out.println(now.get(Calendar.MINUTE)); //minute
System.out.println(now.get(Calendar.SECOND)); //second
System.out.println(now.get(Calendar.MILLISECOND)); //ms