beginDate = new Date(2005, 10 , 1);
endDate  = new Date();         // 当前为2005-10-18System.out.println(endDate.getTime());
System.out.println(beginDate.getTime());
最中输出:
1129568170640
61088918400000为什么当前的时间比以前的还小呢?

解决方案 »

  1.   

    beginDate = new Date(2005, 10 , 1); 生成的日期是2005年11月1日,
    2005-10-18比它小。beginDate = new Date(2005, 9 , 1); 才是2005-10-01
      

  2.   

    up!!!! new date()中的月份要注意
      

  3.   

    “beginDate = new Date(2005, 9 , 1); 才是2005-10-01”也是不对的。beginDate = new Date(105, 9, 1); 才表示 2005-10-1
    new Date(2005, 9, 1); 表示3905年10月1日
      

  4.   

    Date 的 Date( int year, int month, int date ) 这个构造函数,以及 getYear, setYear 都是不推荐使用的方法。正确的方法应该是:Calendar cal = Calendar.getInstance();
    cal.set(2005, Calendar.OCTOBER, 1)cal.getTimeInMillis();
      

  5.   

    Date( int year, int month, int date ) 这个构造函数在1。4不推荐使用
      

  6.   

    A year y is represented by the integer y - 1900. 
    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