public static Duration parse(String str) {
        if (StringUtils.isBlank(str)) {
            return DEFAULT_DURATION;
        }

        if (SIMPLE.matcher(str).matches()) {
            if (str.contains(MILLIS_SECOND_UNIT)) {
                long value = doParse(MILLIS_SECOND_UNIT, str);
                return Duration.ofMillis(value);
            } else if (str.contains(DAY_UNIT)) {
                long value = doParse(DAY_UNIT, str);
                return Duration.ofDays(value);
            } else if (str.contains(HOUR_UNIT)) {
                long value = doParse(HOUR_UNIT, str);
                return Duration.ofHours(value);
            } else if (str.contains(MINUTE_UNIT)) {
                long value = doParse(MINUTE_UNIT, str);
                return Duration.ofMinutes(value);
            } else if (str.contains(SECOND_UNIT)) {
                long value = doParse(SECOND_UNIT, str);
                return Duration.ofSeconds(value);
            } else {
                throw new UnsupportedOperationException("\"" + str + "\" can't parse to Duration");
            }
        }

        try {
            if (ISO8601.matcher(str).matches()) {
                return Duration.parse(str);
            }
        } catch (DateTimeParseException e) {
            throw new UnsupportedOperationException("\"" + str + "\" can't parse to Duration", e);
        }

        try {
            int millis = Integer.parseInt(str);
            return Duration.ofMillis(millis);
        } catch (Exception e) {
            throw new UnsupportedOperationException("\"" + str + "\" can't parse to Duration", e);
        }
    }
@Test
    public void testParse() {
        Assertions.assertEquals(-1L, DurationUtil.parse("").getSeconds());
        Assertions.assertEquals(0L, DurationUtil.parse("8").getSeconds());
        Assertions.assertEquals(8L, DurationUtil.parse("8").toMillis());
        Assertions.assertEquals(0L, DurationUtil.parse("8ms").getSeconds());
        Assertions.assertEquals(8L, DurationUtil.parse("8ms").toMillis());
        Assertions.assertEquals(8L, DurationUtil.parse("8s").getSeconds());
        Assertions.assertEquals(480L, DurationUtil.parse("8m").getSeconds());
        Assertions.assertEquals(28800L, DurationUtil.parse("8h").getSeconds());
        Assertions.assertEquals(691200L, DurationUtil.parse("8d").getSeconds());

        Assertions.assertEquals(172800L,DurationUtil.parse("P2D").getSeconds());
        Assertions.assertEquals(20L,DurationUtil.parse("PT20.345S").getSeconds());
        Assertions.assertEquals(20345L,DurationUtil.parse("PT20.345S").toMillis());
        Assertions.assertEquals(900L,DurationUtil.parse("PT15M").getSeconds());
        Assertions.assertEquals(36000L,DurationUtil.parse("PT10H").getSeconds());
        Assertions.assertEquals(8L,DurationUtil.parse("PT8S").getSeconds());
        Assertions.assertEquals(86460L,DurationUtil.parse("P1DT1M").getSeconds());
        Assertions.assertEquals(183840L,DurationUtil.parse("P2DT3H4M").getSeconds());
        Assertions.assertEquals(-21420L,DurationUtil.parse("PT-6H3M").getSeconds());
        Assertions.assertEquals(-21780L,DurationUtil.parse("-PT6H3M").getSeconds());
        Assertions.assertEquals(21420L,DurationUtil.parse("-PT-6H+3M").getSeconds());
    }