当前位置: 技术问答>java相关
菜鸟想问:如何在我的jsp页面上显示系统的日期和时间???
来源: 互联网 发布时间:2015-10-01
本文导语: 菜鸟想问:如何在我的jsp页面上显示系统的日期和时间??? | 便宜: | //取得当前时间[date] Calendar calendar=Calendar.getInstance(); int year=calendar.get(Calendar.YEAR); int month=...
菜鸟想问:如何在我的jsp页面上显示系统的日期和时间???
|
便宜:
|
//取得当前时间[date]
Calendar calendar=Calendar.getInstance();
int year=calendar.get(Calendar.YEAR);
int month=calendar.get(Calendar.MONTH)+1;
int day=calendar.get(Calendar.DATE);
int hour=calendar.get(Calendar.HOUR_OF_DAY);
int minute=calendar.get(Calendar.MINUTE);
int second=calendar.get(Calendar.SECOND);
String date=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
out.println(date);
Calendar calendar=Calendar.getInstance();
int year=calendar.get(Calendar.YEAR);
int month=calendar.get(Calendar.MONTH)+1;
int day=calendar.get(Calendar.DATE);
int hour=calendar.get(Calendar.HOUR_OF_DAY);
int minute=calendar.get(Calendar.MINUTE);
int second=calendar.get(Calendar.SECOND);
String date=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
out.println(date);
|
|
记得在页面开始部分加上:
|
|
today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i