class DurationParser {

  public static Duration parse(final String text) {
    try {
      final String[] parts = text.split("\\s");
      if (parts.length != 2) {
        throw new IllegalArgumentException("Expected 2 tokens, got: " + parts.length);
      }

      final long size = parseNumeric(parts[0]);
      final TimeUnit timeUnit = parseTimeUnit(parts[1].toUpperCase());

      return Duration.ofNanos(timeUnit.toNanos(size));
    } catch (final Exception e) {
      throw new IllegalArgumentException("Invalid duration: '" + text + "'. " + e.getMessage(), e);
    }
  }

  private  DurationParser();

}