beginDate = new Date(2005, 10 , 1);
endDate = new Date(); // 当前为2005-10-18System.out.println(endDate.getTime());
System.out.println(beginDate.getTime());
最中输出:
1129568170640
61088918400000为什么当前的时间比以前的还小呢?
endDate = new Date(); // 当前为2005-10-18System.out.println(endDate.getTime());
System.out.println(beginDate.getTime());
最中输出:
1129568170640
61088918400000为什么当前的时间比以前的还小呢?
2005-10-18比它小。beginDate = new Date(2005, 9 , 1); 才是2005-10-01
new Date(2005, 9, 1); 表示3905年10月1日
cal.set(2005, Calendar.OCTOBER, 1)cal.getTimeInMillis();
A month is represented by an integer from 0 to 11; 0 is January, 1 is February, and so forth; thus 11 is December.
A date (day of month) is represented by an integer from 1 to 31 in the usual manner.
An hour is represented by an integer from 0 to 23. Thus, the hour from midnight to 1 a.m. is hour 0, and the hour from noon to 1 p.m. is hour 12.
A minute is represented by an integer from 0 to 59 in the usual manner.
A second is represented by an integer from 0 to 61; the values 60 and 61 occur only for leap seconds and even then only in Java implementations that actually track leap seconds correctly. Because of the manner in which leap seconds are currently introduced, it is extremely unlikely that two leap seconds will occur in the same minute, but this specification follows the date and time conventions for ISO C.
这么设置时间好像是不对的,要把年-1900