第一种
try {
long t=0;Date date1 = new SimpleDateFormat("yyyy-mm-dd").parse(s1);
Date date2 = new SimpleDateFormat("yyyy-mm-dd").parse(s2);
t=(date2.getTime()-date1.getTime())/86400000;
System.out.print(t);
}
catch (ParseException e) {
e.printStackTrace();
}
第二种
/*DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try
{
Date d1 = df.parse("2004-03-26");
Date d2 = df.parse("2004-03-29");
long diff = d1.getTime() - d2.getTime();
long days = diff / (1000 * 60 * 60 * 24);
System.out.print(days);
}
catch (Exception e)
{
}*/