protected Object parse(Object value, String pattern) throws ParseException {

        String result = null;

        if ((value instanceof Integer) ||
                (value instanceof Long) ||
                (value instanceof BigInteger) ||
                (value instanceof Byte) ||
                (value instanceof Short)) {

            result = getDecimalFormat(locale, pattern).format(((Number) value).longValue());
        }
        else if ((value instanceof Double) ||
                (value instanceof BigDecimal) ||
                (value instanceof Float)) {

            result = getDecimalFormat(locale, pattern).format(((Number) value).doubleValue());
        }
        else if (value instanceof Date) { // java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp

            SimpleDateFormat dateFormat =
                    new SimpleDateFormat(pattern, locale);

            result = dateFormat.format(value);
        }
        else {
            result = value.toString();
        }

        return result;
    }