0
我有一個CountDownTimer
,我想顯示未來兩週的計數,應該從13d:00h:00:59s
開始倒計時。然而,下面的一段代碼給了我一個我不明白的結果。Android的CountDownTimer
354h:16m:59s
這裏是我的代碼。
public class CounterClass1 extends CountDownTimer {
public CounterClass1(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(long millisUntilFinished) {
diffDays.setText("League finishes in: " +
String.format("%02dd:%02dh:%02dm:%02ds",
TimeUnit.MILLISECONDS.toDays(millisUntilFinished),
TimeUnit.MILLISECONDS.toHours(millisUntilFinished) -
TimeUnit.MILLISECONDS.toDays(
TimeUnit.DAYS.toDays(millisUntilFinished)),
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) -
TimeUnit.HOURS.toMinutes(
TimeUnit.MILLISECONDS.toHours(millisUntilFinished)),
TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) -
TimeUnit.MINUTES.toSeconds(
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished))));
}
@Override
public void onFinish() {
//diffDays.setText("Completed");
}
}
任何建議真的會有所幫助。
謝謝, Theo。
'DAYS.toDays'讓你通過了好些日子代表的天數。 (即它返回輸入) – njzk2