docs: public static long parseDuration(String input,
              ConfigOrigin originForException, String pathForException) {
          String s = ConfigImplUtil.unicodeTrim(input);
          String originalUnitString = getUnits(s);
          String unitString = originalUnitString;
          String numberString = ConfigImplUtil.unicodeTrim(s.substring(0, s.length()
                  - unitString.length()));
          TimeUnit units = null;
  
          // this would be caught later anyway, but the error message
          // is more helpful if we check it here.
          if (numberString.length() == 0)
              throw new ConfigException.BadValue(originForException,
                      pathForException, "No number in duration value '" + input
                              + "'");
  
          if (unitString.length() > 2 && !unitString.endsWith("s"))
              unitString = unitString + "s";
  
          // note that this is deliberately case-sensitive
          if (unitString.equals("") || unitString.equals("ms")
                  || unitString.equals("milliseconds")) {
              units = TimeUnit.MILLISECONDS;
          } else if (unitString.equals("us") || unitString.equals("microseconds")) {
              units = TimeUnit.MICROSECONDS;
          } else if (unitString.equals("ns") || unitString.equals("nanoseconds")) {
              units = TimeUnit.NANOSECONDS;
          } else if (unitString.equals("d") || unitString.equals("days")) {
              units = TimeUnit.DAYS;
          } else if (unitString.equals("h") || unitString.equals("hours")) {
              units = TimeUnit.HOURS;
          } else if (unitString.equals("s") || unitString.equals("seconds")) {
              units = TimeUnit.SECONDS;
          } else if (unitString.equals("m") || unitString.equals("minutes")) {
              units = TimeUnit.MINUTES;
          } else {
              throw new ConfigException.BadValue(originForException,
                      pathForException, "Could not parse time unit '"
                              + originalUnitString
                              + "' (try ns, us, ms, s, m, d)");
          }
  
          try {
              // if the string is purely digits, parse as an integer to avoid
              // possible precision loss;
              // otherwise as a double.
              if (numberString.matches("[0-9]+")) {
                  return units.toNanos(Long.parseLong(numberString));
              } else {
                  long nanosInUnit = units.toNanos(1);
                  return (long) (Double.parseDouble(numberString) * nanosInUnit);
              }
          } catch (NumberFormatException e) {
              throw new ConfigException.BadValue(originForException,
                      pathForException, "Could not parse duration number '"
                              + numberString + "'");
          }
      }