GregorianCalendar currentDay = new GregorianCalendar();
int year= currentDay.get(Calendar.YEAR);
int month=currentDay.get(Calendar.MONTH);
int today=currentDay.get(Calendar.DAY_OF_MONTH);
int hour=currentDay.get(Calendar.HOUR_OF_DAY);
int minute=currentDay.get(Calendar.MINUTE_OF_DAY);
out.println(year+"年"+ (month+1)+"月"+today+"日"+hour+"时");
怎么总是提示分钟那一句有错误?
------解决方案--------------------
没有MINUTE_OF_DAY这个field
换MINUTE吧
------解决方案--------------------
<%
request.setCharacterEncoding("gb2312");
GregorianCalendar currentDay = new GregorianCalendar();
int year= currentDay.get(Calendar.YEAR);
int month=currentDay.get(Calendar.MONTH);
int today=currentDay.get(Calendar.DAY_OF_MONTH);
int hour=currentDay.get(Calendar.HOUR_OF_DAY);
int minute=currentDay.get(Calendar.MINUTE);
out.println(year+"年"+ (month+1)+"月"+today+"日"+hour+"时"+minute+"分");
%>
正如你说的,Calendar.MINUTE_OF_DAY 的类型 不能解析,我换成这个Calendar.MINUTE 就可以了。输出如下:
2008年4月3日17时2分