0

I'm using the below code to display a timer in the format "hh:mm:ss" and countdown from one day, however I get this output. How do I fix this?

 new CountDownTimer(86400000, 1000) { // adjust the milli seconds here

        public void onTick(long millisUntilFinished) {
            _tv.setText(""+String.format("%d H, %d MIN, %d SEC",
                    TimeUnit.MILLISECONDS.toHours(millisUntilFinished),
                    TimeUnit.MILLISECONDS.toMinutes( millisUntilFinished),
                    TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) -
                            TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished))));
        }

        public void onFinish() {
            _tv.setText("PLAY NOW!");
        }
    }.start();

enter image description here

Mike Laren
  • 8,028
  • 17
  • 51
  • 70
Alk
  • 5,215
  • 8
  • 47
  • 116
  • possible duplicate of [How to convert milliseconds to "hh:mm:ss" format?](http://stackoverflow.com/questions/9027317/how-to-convert-milliseconds-to-hhmmss-format) – varren Jun 10 '15 at 00:47
  • @varren It's not a duplicate, I know how to convert, I'm just asking what the error is that creates this output – Alk Jun 10 '15 at 00:48
  • 1
    `TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),` exactly the same problem as in http://stackoverflow.com/questions/9027317/how-to-convert-milliseconds-to-hhmmss-format – varren Jun 10 '15 at 00:49

0 Answers0