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();
}
我已经尝试使用上面的代码来查找两个时间值之间的差异,但它不起作用,这个错误来了:
12-25 09:00:56.537: W/System.err(1642): java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date