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 , ' ' ) ; }
Center string .