public static String alignCenter(String substring, int totalWidth, char fill) {
        if (substring.length() > totalWidth) {
            return substring.substring(0, totalWidth);
        } else {
            final double padding = (totalWidth - substring.length()) / 2d;
            final int left  = (int) Math.floor(padding);
            final int right = (int) Math.ceil(padding);
            return repeat("" + fill, left) + substring + repeat("" + fill, right);
        }
    }
Returns a string of the specified length where the substring is located
in the middle, padded with a character on both sides. If uneven, an extra
space will be added to the right side. If the specified 
{@code totalWidth} is less than the length of the substring, the
substring is returned but with the overflowing characters removed.

@param substring   the substring to align
@param totalWidth  the width of the returned string
@param fill        the character to use for padding
@return            the padded string
common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/util/TextUtil.java