diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/formatting/time/TimeAmountFormatter.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/formatting/time/TimeAmountFormatter.java index 26c88659e..f0c9ae911 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/formatting/time/TimeAmountFormatter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/formatting/time/TimeAmountFormatter.java @@ -107,18 +107,20 @@ public class TimeAmountFormatter implements Formatter { } private void appendSeconds(StringBuilder builder, long seconds, long minutes, long hours, String fHours, String fMinutes, String fSeconds) { - String s = fSeconds.replace(SECONDS_PH, String.valueOf(seconds)); - if (minutes == 0 && s.contains(MINUTES_PH)) { - if (hours == 0 && fMinutes.contains(HOURS_PH)) { - builder.append(fHours.replace(ZERO_PH, "0").replace(HOURS_PH, "0")); + 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)) { + builder.append(fHours.replace(ZERO_PH, "0").replace(HOURS_PH, "0")); + } + builder.append(fMinutes.replace(HOURS_PH, "").replace(ZERO_PH, "0").replace(MINUTES_PH, "0")); } - builder.append(fMinutes.replace(HOURS_PH, "").replace(ZERO_PH, "0").replace(MINUTES_PH, "0")); + s = s.replace(MINUTES_PH, ""); + if (s.contains(ZERO_PH) && String.valueOf(seconds).length() == 1) { + builder.append('0'); + } + builder.append(s); } - s = s.replace(MINUTES_PH, ""); - if (s.contains(ZERO_PH) && String.valueOf(seconds).length() == 1) { - builder.append('0'); - } - builder.append(s); } private void appendDays(StringBuilder builder, long days) { diff --git a/Plan/common/src/test/java/com/djrapitops/plan/data/store/mutators/formatting/TimeAmountFormatterDefaultTest.java b/Plan/common/src/test/java/com/djrapitops/plan/data/store/mutators/formatting/TimeAmountFormatterDefaultTest.java index 1bc7f868f..b2fb15ba1 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/data/store/mutators/formatting/TimeAmountFormatterDefaultTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/data/store/mutators/formatting/TimeAmountFormatterDefaultTest.java @@ -114,7 +114,7 @@ class TimeAmountFormatterDefaultTest { @Test void exampleZero() { - String expected = "-"; + String expected = "0s"; long ms = 0L; String result = underTest.apply(ms); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/data/store/mutators/formatting/TimeAmountFormatterExtraZerosTest.java b/Plan/common/src/test/java/com/djrapitops/plan/data/store/mutators/formatting/TimeAmountFormatterExtraZerosTest.java index ce28b94e4..99ec9aa98 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/data/store/mutators/formatting/TimeAmountFormatterExtraZerosTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/data/store/mutators/formatting/TimeAmountFormatterExtraZerosTest.java @@ -112,7 +112,7 @@ class TimeAmountFormatterExtraZerosTest { @Test void exampleZero() { - String expected = "-"; + String expected = "00:00:00"; long ms = 0L; String result = underTest.apply(ms);