MediaTimeUtils { static String getPlaybackTime(long timeMillis) { final int timeSeconds = (int) (timeMillis / 1000); final int seconds = timeSeconds % 60; final int minutes = (timeSeconds / 60) % 60; final int hours = timeSeconds / 3600; if (hours > 0) { return String.format(Locale.getDefault(), TIME_FORMAT_LONG, hours, minutes, seconds); } else { return String.format(Locale.getDefault(), TIME_FORMAT_SHORT, minutes, seconds); } } private  MediaTimeUtils();   }
@Test public void testFormatPlaybackTime() { assertEquals("0:01", MediaTimeUtils.getPlaybackTime(SECOND_IN_MS)); assertEquals("1:01", MediaTimeUtils.getPlaybackTime(MINUTE_IN_MS + SECOND_IN_MS)); assertEquals("1:01:01", MediaTimeUtils .getPlaybackTime(HOUR_IN_MS + MINUTE_IN_MS + SECOND_IN_MS)); }