当前位置: 技术问答>java相关
为何取出的时间不是当前时间????????
来源: 互联网 发布时间:2015-03-08
本文导语: 现在北京时间是23日11:44 本地时间也是23日11:44 但用如下JSP运行后,时间就是 Day of month: is 22 Year: is 2001 Month: is December Time: is 19:43:27 Date: is 12/22/2001 Day: is Saturday Day Of Year: is 356 Week Of Year: is...
现在北京时间是23日11:44
本地时间也是23日11:44
但用如下JSP运行后,时间就是
Day of month: is 22
Year: is 2001
Month: is December
Time: is 19:43:27
Date: is 12/22/2001
Day: is Saturday
Day Of Year: is 356
Week Of Year: is 51
era: is 1
DST Offset: is 0
Zone Offset: is -8
源程序:
本地时间也是23日11:44
但用如下JSP运行后,时间就是
Day of month: is 22
Year: is 2001
Month: is December
Time: is 19:43:27
Date: is 12/22/2001
Day: is Saturday
Day Of Year: is 356
Week Of Year: is 51
era: is 1
DST Offset: is 0
Zone Offset: is -8
源程序:
- Day of month: is
- Year: is
- Month: is
- Time: is
- Date: is
- Day: is
- Day Of Year: is
- Week Of Year: is
- era: is
- DST Offset: is
- Zone Offset: is
|
dates.JspCalendar是哪来的?
在Java的日期中,年月日取到的数值并不全是从1到从0开始记数的。
它的月是从1开始记数,这样你得到的数值正好和实际值一样。而年,日从0开始记数,当然就差一了。不知是不是这原因?
如果上面的dates.JspCalendar是自己开发的,可以从那里改。
在Java的日期中,年月日取到的数值并不全是从1到从0开始记数的。
它的月是从1开始记数,这样你得到的数值正好和实际值一样。而年,日从0开始记数,当然就差一了。不知是不是这原因?
如果上面的dates.JspCalendar是自己开发的,可以从那里改。
|
Calendar calendar=java.util.Calendar.getInstance();
int year = calendar.get(calendar.YEAR);
int month = calendar.get(calendar.MONTH) + 1;
int day = calendar.get(calendar.DATE);
String s = "";
s = String.valueOf(year);
if(month
int year = calendar.get(calendar.YEAR);
int month = calendar.get(calendar.MONTH) + 1;
int day = calendar.get(calendar.DATE);
String s = "";
s = String.valueOf(year);
if(month