void () { NlsMessages.NlsDurationFormatter formatter = new NlsMessages.NlsDurationFormatter() .setNarrow(false).setDurationTimeUnit(TimeUnit.MILLISECONDS).setPadded(true); assertEquals("0ms", formatter.formatDuration(0)); assertEquals("1s 000ms", formatter.formatDuration(1000)); assertEquals("1s 001ms", formatter.formatDuration(1001)); assertEquals("2m 00s 000ms", formatter.formatDuration(TimeUnit.MINUTES.toMillis(2))); assertEquals("2h 00m 00s 000ms", formatter.formatDuration(TimeUnit.HOURS.toMillis(2))); assertEquals("2d 00h 00m 00s 000ms", formatter.formatDuration(TimeUnit.DAYS.toMillis(2))); assertEquals("204,978w 6d 16h 13m 50s 987ms", formatter.formatDuration(123971271230987L)); formatter.setDurationTimeUnit(TimeUnit.DAYS); assertEquals("1d", formatter.formatDuration(1)); formatter.setDurationTimeUnit(TimeUnit.MILLISECONDS); assertEquals("1m 00s 100ms", formatter.formatDuration(60100)); }