时间比对

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    //得到指定模范的时间
   Date d1 = sdf.parse(s1);
    Date d2 = sdf.parse(s2);
    //比较
   if(Math.abs(((d1.getTime() - d2.getTime())/(24*3600*1000))) >=3) {
     System.out.println("大于三天");
     a="大于三天";
    }else{
     System.out.println("小于三天");
     a="小于三天";
    } 

猜你喜欢

转载自findshop.iteye.com/blog/2195079