SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss");
try {
Date date = (Date) format.parse(a);
Date date1 = (Date) format.parse(b1);
Date date2 = (Date) format.parse(c);
long diff1 = date1.getTime()-date.getTime();
long diff2 = date2.getTime()- date.getTime();
bundle.putLong("df1", diff1);
bundle.putLong("df2", diff2);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我已經嘗試了上面的代碼查找兩個時間值,但它不工作的區別,這個錯誤來了:如何在android中查找兩個時間值的區別?
12-25 09:00:56.537: W/System.err(1642): java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date