code: static Duration duration(String value) {
          Duration result;
          if (value != null) {
              value = value.trim();
              Matcher matcher = DURATION_PATTERN.matcher(value);
              if (matcher.matches()) {
                  int hours = matcher.group(1) != null ? Integer.parseInt(matcher.group(1)) : 0;
                  int minutes = matcher.group(2) != null ? Integer.parseInt(matcher.group(2)) : 0;
                  int seconds = matcher.group(3) != null ? Integer.parseInt(matcher.group(3)) : 0;
                  int millis = matcher.group(4) != null ? Integer.parseInt(matcher.group(4)) : 0;
                  result = new Duration(hours, minutes, seconds, millis);
              } else {
                  throw new IllegalArgumentException("Unknown format for value: " + value);
              }
          } else {
              result = null;
          }
          return result;
      }
docs: Convert a string to a duration.
  
  @param value value to convert
  @return converted value, or <code>null</code> if the supplied value was <code>null</code>
  @throws IllegalArgumentException if the supplied value could not be parsed