public long parseDuration(final String textualDuration) throws ParsingException {
        // We can't use Matcher.results, as it is only available on Android 14 and above
        final Matcher matcher = DURATION_PATTERN.matcher(textualDuration);
        final List<MatchResult> results = new ArrayList<>();
        while (matcher.find()) {
            results.add(matcher.toMatchResult());
        }

        return results.stream()
                .map(match -> {
                    final String digits = match.group(1);
                    final String word = match.group(2);

                    int amount;
                    try {
                        amount = Integer.parseInt(digits);
                    } catch (final NumberFormatException ignored) {
                        amount = 1;
                    }

                    final ChronoUnit unit;
                    try {
                        unit = parseChronoUnit(word);
                    } catch (final ParsingException ignored) {
                        return 0L;
                    }

                    return amount * unit.getDuration().getSeconds();
                })
                .filter(n -> n > 0)
                .reduce(Long::sum)
                .orElseThrow(() -> new ParsingException(
                        "Could not parse duration \"" + textualDuration + "\""));
    }
@Test
    void testGetDuration() throws ParsingException {
        assertEquals(1, timeAgoParser.parseDuration("one second"));
        assertEquals(1, timeAgoParser.parseDuration("second"));
        assertEquals(49, timeAgoParser.parseDuration("49 seconds"));
        assertEquals(61, timeAgoParser.parseDuration("1 minute, 1 second"));
    }