mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-09 09:57:35 +01:00
Fixed TimeAmountFormatter 0s formatting
This commit is contained in:
parent
93600b74ed
commit
ad7f8c5631
@ -107,18 +107,20 @@ public class TimeAmountFormatter implements Formatter<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void appendSeconds(StringBuilder builder, long seconds, long minutes, long hours, String fHours, String fMinutes, String fSeconds) {
|
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 (seconds != 0 || fSeconds.contains(ZERO_PH)) {
|
||||||
if (minutes == 0 && s.contains(MINUTES_PH)) {
|
String s = fSeconds.replace(SECONDS_PH, String.valueOf(seconds));
|
||||||
if (hours == 0 && fMinutes.contains(HOURS_PH)) {
|
if (minutes == 0 && s.contains(MINUTES_PH)) {
|
||||||
builder.append(fHours.replace(ZERO_PH, "0").replace(HOURS_PH, "0"));
|
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) {
|
private void appendDays(StringBuilder builder, long days) {
|
||||||
|
@ -114,7 +114,7 @@ class TimeAmountFormatterDefaultTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void exampleZero() {
|
void exampleZero() {
|
||||||
String expected = "-";
|
String expected = "0s";
|
||||||
|
|
||||||
long ms = 0L;
|
long ms = 0L;
|
||||||
String result = underTest.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
@ -112,7 +112,7 @@ class TimeAmountFormatterExtraZerosTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void exampleZero() {
|
void exampleZero() {
|
||||||
String expected = "-";
|
String expected = "00:00:00";
|
||||||
|
|
||||||
long ms = 0L;
|
long ms = 0L;
|
||||||
String result = underTest.apply(ms);
|
String result = underTest.apply(ms);
|
||||||
|
Loading…
Reference in New Issue
Block a user