Date endTime = activity.getEndTime();
Date startTime = new Date();
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(startTime);
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(endTime);
Long endSecond = endCalendar.getTimeInMillis();
Long startSecond = startCalendar.getTimeInMillis();
Long balance = endSecond-startSecond;
Integer s_day = 60*60*24*1000;
Integer s_hour = 60*60*1000;
Integer s_min = 60*1000;
Long day = balance/s_day;//还剩多少天
Long hour = (balance-day*s_day)/s_hour;//还剩多少小时
Long min = (balance-day*s_day-hour*s_hour)/s_min;//还剩多少分钟
Long sec = (balance-day*s_day-hour*s_hour-min*s_min)/1000;//还剩多少秒
计算两个时间的差值
最新推荐文章于 2023-06-26 16:33:19 发布