### Question:
B2DateTimeUtil { public static String durationString(long deltaSecs) { String s = ""; boolean wasNegative = (deltaSecs < 0); if (wasNegative) { deltaSecs = -deltaSecs; } if (deltaSecs >= ONE_DAY_IN_SECONDS) { final long nDays = deltaSecs / ONE_DAY_IN_SECONDS; s += nDays + "d"; deltaSecs -= nDays * ONE_DAY_IN_SECONDS; } if (deltaSecs >= ONE_HOUR_IN_SECONDS) { final long nHours = deltaSecs / ONE_HOUR_IN_SECONDS; s += nHours + "h"; deltaSecs -= nHours * ONE_HOUR_IN_SECONDS; } if (deltaSecs >= ONE_MINUTE_IN_SECONDS) { final long nMins = deltaSecs / ONE_MINUTE_IN_SECONDS; s += nMins + "m"; deltaSecs -= nMins * ONE_MINUTE_IN_SECONDS; } if (deltaSecs > 0) { s += deltaSecs + "s"; } if (s.length() == 0) { s = "0s"; } if (wasNegative) { s = "-" + s; } return s; } B2DateTimeUtil(); static String formatSolidDate(LocalDate date); static LocalDateTime parseDateTime(String str); static String formatFguidDateTime(LocalDateTime dateTime); static Duration parseDuration(String str); static String durationString(long deltaSecs); static final long ONE_SECOND_IN_MILLIS; static final int MIN_YEAR; static final int MAX_YEAR; static final int MIN_MONTH; static final int MAX_MONTH; static final int MIN_DAY; static final int MAX_DAY; }### Answer:
@Test public void checkDurationString() { final long S = 1; final long M = B2DateTimeUtil.ONE_MINUTE_IN_SECONDS; final long H = B2DateTimeUtil.ONE_HOUR_IN_SECONDS; final long D = B2DateTimeUtil.ONE_DAY_IN_SECONDS; Assert.assertEquals("1d2h3m4s", B2DateTimeUtil.durationString(D + 2 * H + 3 * M + 4 * S)); Assert.assertEquals("-1d2h3m4s", B2DateTimeUtil.durationString(-(D + 2 * H + 3 * M + 4 * S))); Assert.assertEquals("366d", B2DateTimeUtil.durationString(366 * D)); Assert.assertEquals("23h", B2DateTimeUtil.durationString(23 * H)); Assert.assertEquals("59m", B2DateTimeUtil.durationString(59 * M)); Assert.assertEquals("59s", B2DateTimeUtil.durationString(59 * S)); Assert.assertEquals("-59s", B2DateTimeUtil.durationString(-59 * S)); Assert.assertEquals("0s", B2DateTimeUtil.durationString(0)); Assert.assertEquals("1d1h1m1s", B2DateTimeUtil.durationString(D + H + M + S)); }