SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
        Date d1=sdf.parse("2017-9-5 10:10:10");  
        Date d2=sdf.parse("2017-9-4 11:11:11");  
        

        Calendar  calendar =Calendar.getInstance();//日历类
	calendar.setTime(d2);
	double now_date =calendar.getTimeInMillis();
	calendar.setTime(d1);
	double overdue_time=calendar.getTimeInMillis();
	double overdueDate=(now_date-overdue_time)/(1000*3600*24); 
	System.out.println(overdueDate);

结果为:

 -0.9576273148148148

延伸:

 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 Date a = sdf.parse("2019-06-20");
 Date d = sdf.parse("2019-07-20");
//查询时间是否早于d时间
boolean flag=sdf.parse(a).before(d);
if (flag){
   //a时间早于d时间
             
}else {
  //a时间晚于d时间
          
}