code: public void format(final int fieldStart, final StringBuffer buffer) {
      final int rawLength = buffer.length() - fieldStart;
  
      if (rawLength > maxLength) {
        if(rightTruncate) {
           buffer.setLength(fieldStart + maxLength);
        } else {
           buffer.delete(fieldStart, buffer.length() - maxLength);
        }
      } else if (rawLength < minLength) {
        if (leftAlign) {
          final int fieldEnd = buffer.length();
          buffer.setLength(fieldStart + minLength);
  
          for (int i = fieldEnd; i < buffer.length(); i++) {
            buffer.setCharAt(i, ' ');
          }
        } else {
          int padLength = minLength - rawLength;
  
          for (; padLength > 8; padLength -= 8) {
            buffer.insert(fieldStart, SPACES);
          }
  
          buffer.insert(fieldStart, SPACES, 0, padLength);
        }
      }
    }
docs: Adjust the content of the buffer based on the specified lengths and alignment.
  
  @param fieldStart start of field in buffer.
  @param buffer buffer to be modified.