### Question:
B2DateTimeUtil { public static Duration parseDuration(String str) { try { return new DurationParser(str).getDuration(); } catch (IllegalArgumentException e) { return null; } } 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 testParseDuration() { 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; assertNull(B2DateTimeUtil.parseDuration(null)); assertNull(B2DateTimeUtil.parseDuration("")); assertNull(B2DateTimeUtil.parseDuration("-")); assertNull(B2DateTimeUtil.parseDuration("1")); assertNull(B2DateTimeUtil.parseDuration("1a")); assertNull(B2DateTimeUtil.parseDuration("1s2d")); assertNull(B2DateTimeUtil.parseDuration("1ha")); checkParseDuration("366d", 366 * D); checkParseDuration("23h", 23 * H); checkParseDuration("59m", 59 * M); checkParseDuration("59s", 59 * S); checkParseDuration("-59s", -59 * S); checkParseDuration("0s", 0); checkParseDuration("1d2h3m4s", D + 2 * H + 3 * M + 4 * S); checkParseDuration("-1d2h3m4s", -(D + 2 * H + 3 * M + 4 * S)); }