long ms = time % 1000;
final String format;
if (h > 0) {
- format = "%1$d:%2$02d:%3$02d.%4$03ds";
+ format = "%1$d:%2$02d:%3$02d.%4$03d s";
} else if (m > 0) {
- format = "%2$d:%3$02d.%4$03ds";
+ format = "%2$d:%3$02d.%4$03d s";
} else {
- format = "%3$d.%4$03ds";
+ format = "%3$d.%4$03d s";
}
return String.format(format, h, m, s, ms);
}
@Test
public void shouldFormatTime() {
- assertThat(GlobalContainer.formatTime(1 * 60 * 60 * 1000 + 2 * 60 * 1000 + 3 * 1000 + 400)).isEqualTo("1:02:03.400s");
- assertThat(GlobalContainer.formatTime(2 * 60 * 1000 + 3 * 1000 + 400)).isEqualTo("2:03.400s");
- assertThat(GlobalContainer.formatTime(3 * 1000 + 400)).isEqualTo("3.400s");
- assertThat(GlobalContainer.formatTime(400)).isEqualTo("0.400s");
+ assertThat(GlobalContainer.formatTime(1 * 60 * 60 * 1000 + 2 * 60 * 1000 + 3 * 1000 + 400)).isEqualTo("1:02:03.400 s");
+ assertThat(GlobalContainer.formatTime(2 * 60 * 1000 + 3 * 1000 + 400)).isEqualTo("2:03.400 s");
+ assertThat(GlobalContainer.formatTime(3 * 1000 + 400)).isEqualTo("3.400 s");
+ assertThat(GlobalContainer.formatTime(400)).isEqualTo("0.400 s");
}
@BatchSide