protected char[] formattedValue(final Object val, final ColumnMetaData element) {
        Object value = val;
        if (value == null) {
            // TODO DO: maybe have a way to substitute default values here?
            value = "";
        }

        String stringValue;
        if (value instanceof BigDecimal) {
            final BigDecimal bd = (BigDecimal) value;
            stringValue = bd.signum() == 0 ? "0" : bd.toPlainString();
        } else {
            stringValue = value.toString();
        }

        final int stringLength = stringValue.length();

        final int columnLength = element.getColLength();
        final char[] formattedValue = new char[columnLength];

        /*
         * Copy the contents of the original string; for Strings up to ~8-10
         * characters this loop is consistently faster than String.getChars().
         * Short Strings are usually the majority of values in fixed-width data
         * columns.
         */
        final int numCharacters = Math.min(stringLength, columnLength);
        if (numCharacters < MAX_CHAR_TO_USE_LOOP) {
            for (int i = 0; i < numCharacters; i++) {
                formattedValue[i] = stringValue.charAt(i);
            }
        } else {
            stringValue.getChars(0, numCharacters, formattedValue, 0);
        }

        if (stringLength < columnLength) {
            // pad if necessary
            Arrays.fill(formattedValue, stringLength, columnLength, padChar);
        }

        return formattedValue;
    }