### Question:
DurationFormatter { public String format(Duration duration) { return this.df.formatMillis((long) duration .getValue(TimeUnit.MILLISECONDS)); } DurationFormatter(Type type); String format(Duration duration);  }### Answer:
@Test public void testDigits() { DurationFormatter df = new DurationFormatter(Type.SHORT); Duration secDur = DefaultDuration.of(530, SECONDS); Duration minDur = secDur.convertTo(MINUTES); assertEquals("00:08:50", df.format(secDur)); assertEquals("00:08:50", df.format(minDur)); }
@Test public void testSymbols() { DurationFormatter df = new DurationFormatter(Type.SHORT_SYMBOLS); Duration secDur = DefaultDuration.of(530, SECONDS); Duration minDur = secDur.convertTo(MINUTES); assertEquals("8min 50s", df.format(secDur)); assertEquals("8min 50s", df.format(minDur)); }
@Test public void testSymbols_5m_10m_15m() { DurationFormatter df = new DurationFormatter(Type.SHORT_SYMBOLS); assertEquals("5min", df.format(DefaultDuration.of(5, MINUTES))); assertEquals("10min", df.format(DefaultDuration.of(10, MINUTES))); assertEquals("15min", df.format(DefaultDuration.of(15, MINUTES))); }
@Test public void testSymbols_120m() { DurationFormatter df = new DurationFormatter(Type.SHORT_SYMBOLS); assertEquals("2h", df.format(DefaultDuration.of(120, MINUTES))); }
@Test public void testSymbols_150m() { DurationFormatter df = new DurationFormatter(Type.SHORT_SYMBOLS); assertEquals("2h 30min", df.format(DefaultDuration.of(150, MINUTES))); }