protected Format getFormat()

in src/main/java/org/apache/commons/validator/routines/AbstractNumberValidator.java [115:144]


    protected Format getFormat(final Locale locale) {
        final NumberFormat formatter;
        switch (formatType) {
        case CURRENCY_FORMAT:
            if (locale == null) {
                formatter = NumberFormat.getCurrencyInstance();
            } else {
                formatter = NumberFormat.getCurrencyInstance(locale);
            }
            break;
        case PERCENT_FORMAT:
            if (locale == null) {
                formatter = NumberFormat.getPercentInstance();
            } else {
                formatter = NumberFormat.getPercentInstance(locale);
            }
            break;
        default:
            if (locale == null) {
                formatter = NumberFormat.getInstance();
            } else {
                formatter = NumberFormat.getInstance(locale);
            }
            if (!isAllowFractions()) {
                formatter.setParseIntegerOnly(true);
            }
            break;
        }
        return formatter;
    }