code: public static String center(String s, int length) {
        if (s == null) {
           return null;
        }
        int start = (int) Math.floor(Math.max(0, (length - s.length()) / 2d));
        return padEnd(repeat(' ', start) + s, length, ' ');
     }
docs: Center string.
  
  @param s      the s
  @param length the length
  @return the string