private void appendSegment(StringBuilder buffer, long segment, boolean seconds) {

    if (segment > 0) {
      if ((segment < 10) && (buffer.length() > 0)) {
        buffer.append('0');
      }
      buffer.append(segment);
    } else if (buffer.length() > 0) {
      buffer.append("00");
    } else if (seconds) {
      buffer.append("0");
    } else {
      return;
    }
    if (!seconds) {
      buffer.append(':');
    }
  }
private void appendSegment ( StringBuilder buffer , long segment , boolean seconds ) { if ( segment > 0 ) { if ( ( segment < 10 ) && ( buffer . length ( ) > 0 ) ) { buffer . append ( '0' ) ; } buffer . append ( segment ) ; } else if ( buffer . length ( ) > 0 ) { buffer . append ( "00" ) ; } else if ( seconds ) { buffer . append ( "0" ) ; } else { return ; } if ( ! seconds ) { buffer . append ( ':' ) ; } }
@param buffer is the {@link StringBuilder} to {@link StringBuilder#append(String) append} to.
@param segment is the segment to append (hours, minutes, or seconds).
@param seconds - {@code true} if segment are seconds, {@code false} otherwise.