code: public static String formatDuration(final long durationMillis, final String format, final boolean padWithZeros) {
          Validate.inclusiveBetween(0, Long.MAX_VALUE, durationMillis, "durationMillis must not be negative");
  
          final Token[] tokens = lexx(format);
  
          long days         = 0;
          long hours        = 0;
          long minutes      = 0;
          long seconds      = 0;
          long milliseconds = durationMillis;
  
          if (Token.containsTokenWithValue(tokens, d) ) {
              days = milliseconds / DateUtils.MILLIS_PER_DAY;
              milliseconds = milliseconds - (days * DateUtils.MILLIS_PER_DAY);
          }
          if (Token.containsTokenWithValue(tokens, H) ) {
              hours = milliseconds / DateUtils.MILLIS_PER_HOUR;
              milliseconds = milliseconds - (hours * DateUtils.MILLIS_PER_HOUR);
          }
          if (Token.containsTokenWithValue(tokens, m) ) {
              minutes = milliseconds / DateUtils.MILLIS_PER_MINUTE;
              milliseconds = milliseconds - (minutes * DateUtils.MILLIS_PER_MINUTE);
          }
          if (Token.containsTokenWithValue(tokens, s) ) {
              seconds = milliseconds / DateUtils.MILLIS_PER_SECOND;
              milliseconds = milliseconds - (seconds * DateUtils.MILLIS_PER_SECOND);
          }
  
          return format(tokens, 0, 0, days, hours, minutes, seconds, milliseconds, padWithZeros);
      }
docs: <p>Formats the time gap as a string, using the specified format.
  Padding the left hand side of numbers with zeroes is optional.</p>
  
  <p>This method formats durations using the days and lower fields of the
  format pattern. Months and larger are not used.</p>
  
  @param durationMillis  the duration to format
  @param format  the way in which to format the duration, not null
  @param padWithZeros  whether to pad the left hand side of numbers with 0's
  @return the formatted duration, not null
  @throws java.lang.IllegalArgumentException if durationMillis is negative