code: public static String center(CharSequence self, Number numberOfChars, CharSequence padding) {
          String s = self.toString();
          String padding1 = padding.toString();
          int numChars = numberOfChars.intValue();
          if (numChars <= s.length()) {
              return s;
          } else {
              int charsToAdd = numChars - s.length();
              String semiPad = charsToAdd % 2 == 1 ?
                      getPadding(padding1, charsToAdd / 2 + 1) :
                      getPadding(padding1, charsToAdd / 2);
              if (charsToAdd % 2 == 0)
                  return semiPad + s + semiPad;
              else
                  return semiPad.substring(0, charsToAdd / 2) + s + semiPad;
          }
      }
docs: Pad a CharSequence to a minimum length specified by <tt>numberOfChars</tt>, appending the supplied padding CharSequence around the original as many times as needed keeping it centered.
  
  If the String is already the same size or bigger than the target <tt>numberOfChars</tt>, then the original String is returned. An example:
  <pre>
  ['A', 'BB', 'CCC', 'DDDD'].each{ println '|' + it.center(6, '+') + '|' }
  </pre>
  will produce output like:
  <pre>
  |++A+++|
  |++BB++|
  |+CCC++|
  |+DDDD+|
  </pre>
  
  @param self          a CharSequence object
  @param numberOfChars the total minimum number of characters of the resulting CharSequence
  @param padding       the characters used for padding
  @return the centered toString() of this CharSequence with padded characters around it
  @see #center(String, Number, String)
  @since 1.8.2