Countdown timer in HH:MM:SS format in Android

I am using the below code to convert from duration in seconds to the format HH:MM:SS.

String.format("%02d:%02d:%02d", durationSeconds / 3600,
                (durationSeconds % 3600) / 60, (durationSeconds % 60));

You can easily adjust this to accept input in minutes but then your output will be in the format of HH:MM:00 since you do not have seconds, e.g.:

String.format("%02d:%02d:%02d", durationMinutes / 60, durationMinutes % 60, 0);

String.format("%02d:%02d:%02d",
            TimeUnit.MILLISECONDS.toHours(duration)%60,
            TimeUnit.MILLISECONDS.toMinutes(duration)%60,
            TimeUnit.MILLISECONDS.toSeconds(duration) % 60)