Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
String strMaxDate = "1995-12-06";
String strMinDate = "1995-12-01";
String compile = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat(compile);
try
{
cal1.setTime(new java.sql.Date(sdf.parse(strMaxDate).getTime()));
cal2.setTime(new java.sql.Date(sdf.parse(strMinDate).getTime()));
long lCal1 = cal1.getTimeInMillis();
long lCal2 = cal2.getTimeInMillis();
long l = lCal1 - lCal2;
System.out.println(l/1000/60/60/24);
}
catch (ParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
只能循环算吧?