0
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 秒?

我无法弄清楚算法。

4

2 回答 2

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

这应该会给你你正在寻找的输出。

于 2013-05-12T16:37:12.387 回答
0

你用这段代码得到了什么?据我所知,你唯一缺少的是

hour = min / 60;
于 2013-05-12T16:31:09.103 回答