计算两个时间的分钟差
SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();//现在的时间
java.util.Date d2 = simpleFormat.parse("2017-03-23 15:15:12");//旧的时间
String toDate = simpleFormat.format(now);
String fromDate = simpleFormat.format(d2);
long from = simpleFormat.parse(fromDate).getTime();
long to = simpleFormat.parse(toDate).getTime();
int minutes = (int) ((to - from) / (1000 * 60));
网友评论