计算时间差方法
public static int getDistanceTimemin(String str1, String str2) {DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date one;Date two;long day = 0;//天数差long hour = 0;//小时数差long min = 0;//分钟数差long second=0;//秒数差try {final Calendar c = Calendar.getInstance();c.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));one = df.parse(str1);c.setTime(one);two = df.parse(str2);long time1 = one.getTime();long time2 = two.getTime();long diff ;diff = time2 - time1;day = diff / (24 * 60 * 60 * 1000);
// Log.i("lgq","diff--==="+diff+"...one="+time1+"..-----.two==="+time2);hour = (diff / (60 * 60 * 1000) - day * 24);min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60);second = diff/1000;} catch (ParseException e) {e.printStackTrace();}return (int)min;}
second =((diff / (1000)) - day * 24 * 60*60 - hour * 60*60-min*60);