计算Date间的分钟数

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
Date date_begin = simpleDateFormat.parse(beginTime);
Date date_end = simpleDateFormat.parse(endTime);
Long duration = date_end.getTime() - date_begin.getTime();
// 计算差多少分钟
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
int min = (int) (duration % nd % nh / nm);

ps:long大小不能打与int long.intValue();

16.3.30:写错了

int min = duration/nm

posted @ 2016-03-25 11:38  FEI_>.<_JI  阅读(343)  评论(0编辑  收藏  举报