Fixed TimeAmountFormatter 0s formatting

This commit is contained in:
Rsl1122 2019-07-19 13:02:45 +03:00
parent 93600b74ed
commit ad7f8c5631
3 changed files with 14 additions and 12 deletions

View File

@ -107,6 +107,7 @@ public class TimeAmountFormatter implements Formatter<Long> {
}
private void appendSeconds(StringBuilder builder, long seconds, long minutes, long hours, String fHours, String fMinutes, String fSeconds) {
if (seconds != 0 || fSeconds.contains(ZERO_PH)) {
String s = fSeconds.replace(SECONDS_PH, String.valueOf(seconds));
if (minutes == 0 && s.contains(MINUTES_PH)) {
if (hours == 0 && fMinutes.contains(HOURS_PH)) {
@ -120,6 +121,7 @@ public class TimeAmountFormatter implements Formatter<Long> {
}
builder.append(s);
}
}
private void appendDays(StringBuilder builder, long days) {
String singular = config.get(FormatSettings.DAY);

View File

@ -114,7 +114,7 @@ class TimeAmountFormatterDefaultTest {
@Test
void exampleZero() {
String expected = "-";
String expected = "0s";
long ms = 0L;
String result = underTest.apply(ms);

View File

@ -112,7 +112,7 @@ class TimeAmountFormatterExtraZerosTest {
@Test
void exampleZero() {
String expected = "-";
String expected = "00:00:00";
long ms = 0L;
String result = underTest.apply(ms);