Date lol = c.getTime();
long milli_now = lol.getTime();
c.set(2013, c.MAY, 21);
Date lol1 = c.getTime();
long milli_then = lol1.getTime();
long milli_tot = (milli_then - milli_now);
long sec = (milli_tot/1000);
long min = 0;
long hour = 0;
min = (sec/60);
days.setText("Days left: " + (sec/60/60/24));
countdown.setText(""+hour+":"+min+":"+sec);
我该怎么办才能拥有216小时,60分钟,60秒?
我无法弄清楚算法。
答案 0 :(得分:2)
以下是您可以做的事情:
long totDiff = (lastDate.getTime() - firstDate.getTime()); // Total differance in milliseconds
long Sdiff = (totDiff / 1000) % 60; // Differance in seconds
long Mdiff = (totDiff / (60 * 1000)) %60; // Differance in minutes
long Hdiff = (totDiff / (60 * 60 * 1000)); // Remaining time in hours
这应该可以为您提供所需的输出。
答案 1 :(得分:0)
你对这段代码有什么看法?据我所知,你唯一缺少的是
hour = min / 60;