通过时间戳算出差值,然后再(除以1000为秒,除以1000*60为分,除以1000*60*60为时,除以1000*60*60*24为天)
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date1=null;
Date date2=null;
String time1="2000-01-01 00:00:00";
String time2="2009-03-19 18:37:53.0";
// String timeTest=null;
// String timeTest1=null;
try {
date1=format.parse(time1);
date2=format.parse(time2);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// timeTest=format.format(date1);
// System.out.println(timeTest);
// timeTest1=format.format(date2);
// System.out.println(timeTest1);
Calendar ca1 = Calendar.getInstance();
Calendar ca2 = Calendar.getInstance();
ca1.setTime(date1);
ca2.setTime(date2);
long distanceMin =( ca1.getTimeInMillis()- ca2.getTimeInMillis())/(1000*60*60*24);