我想到拉 :SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd"); 
Date date1 = bartDateFormat.parse(日期1);
Date date2 = bartDateFormat.parse(日期2);输入的 日期1 日期2 变成毫秒数了
在用
double tempTwo = (double)date1;
double tempTwo = (double)date2;在比较两个tempOne  tempTwo  的大小
if(tempTow <= tempOne ){
    tempDate=(tempTwo-tempTwo)/57600000    //java中1天的毫秒数???
}
天数 出来了不可以比较2个都是1970-01-01前的值 
java 的高手给看看啊!

解决方案 »

  1.   

    上面  
    double tempTwo = (double)date1;
    double tempTwo = (double)date2;写的不对用tempTwo.getTimes()
    tempOne.getTimes()
    对返回的long 型整数比较。
      

  2.   

    还有就是:
    tempDate=(tempTwo-tempTwo)/57600000 
    改成 :
    int temp=(int)((date2.getTime()-date.getTime())/86400000);
      

  3.   

    比较两个Date:d1,d2
    int i = d1.compareTo(d2);
    返回-1则d1在d2之前,0相等,1就是d1在d2之后 
    也可以用d1.before(d2)或d1.after(d2)返回为boolean值,更容易至于比较天数差可以这样
    long l1 = d1.getTime();
    long l2 = d2.getTime();
    long l3 = Math.abs(l1-l2);
    int day = (int)l3/24/3600/1000;
      

  4.   

    比较大小,或者前后关系是两个Date:d1,d2
    d1.after(d2);返回boolean值
      

  5.   


    Class Date
    java.lang.Object
      java.util.Date
    boolean after(Date when) 
              Tests if this date is after the specified date. 
    boolean before(Date when) 
              Tests if this date is before the specified date. compareTo
    public int compareTo(Object o)Compares this Date to another Object. If the Object is a Date, this function behaves like compareTo(Date). Otherwise, it throws a ClassCastException (as Dates are comparable only to other Dates). Specified by:
    compareTo in interface Comparable
    Parameters:
    o - the Object to be compared. 
    Returns:
    the value 0 if the argument is a Date equal to this Date; a value less than 0 if the argument is a Date after this Date; and a value greater than 0 if the argument is a Date before this Date. 这几个函数都能满足楼主的要求吧,关于比大小的。
    相差几天的问题,楼上各位说的已经差不多了