public static String formatTime(Duration duration)
    {
        int totalSeconds = Ints.saturatedCast(duration.roundTo(SECONDS));
        if (totalSeconds == 0) {
            return format("%sms", Ints.saturatedCast(duration.roundTo(MILLISECONDS)));
        }
        int minutes = totalSeconds / 60;
        int seconds = totalSeconds % 60;

        return format("%s:%02d", minutes, seconds);
    }
@Test
    public void testFormatTime()
    {
        assertEquals(FormatUtils.formatTime(Duration.succinctNanos(100L)), "0ms");
        assertEquals(FormatUtils.formatTime(Duration.succinctDuration(1.1, TimeUnit.MILLISECONDS)), "1ms");
        assertEquals(FormatUtils.formatTime(Duration.succinctDuration(1.1, TimeUnit.SECONDS)), "0:01");
        assertEquals(FormatUtils.formatTime(Duration.succinctDuration(1.5, TimeUnit.MINUTES)), "1:30");
        assertEquals(FormatUtils.formatTime(Duration.succinctDuration(1.5, TimeUnit.HOURS)), "90:00");
    }