Core/src/main/java/org/openestate/io/core/NumberUtils.java
public static Number parseNumber(String value, boolean integerOnly, Locale... locales) throws NumberFormatException {
        value = StringUtils.trimToNull(value);
        if (value == null) return null;

        // ignore leading plus sign
        if (value.startsWith("+"))
            value = StringUtils.trimToNull(value.substring(1));

        // remove any spaces
        value = StringUtils.replace(value, StringUtils.SPACE, StringUtils.EMPTY);

        if (ArrayUtils.isEmpty(locales))
            locales = new Locale[]{Locale.getDefault()};

        for (Locale locale : locales) {
            // check, if the value is completely numeric for the locale
            if (!isNumeric(value, locale)) continue;
            NumberFormat format = NumberFormat.getNumberInstance(locale);
            try {
                format.setMinimumFractionDigits(0);
                format.setParseIntegerOnly(integerOnly);
                format.setGroupingUsed(value.indexOf(DecimalFormatSymbols.getInstance(locale).getGroupingSeparator()) > -1);
                return format.parse(value);
            } catch (ParseException ex) {
            }
        }
        throw new NumberFormatException("The provided value '" + value + "' is not numeric!");
    }
public static Number parseNumber(String value, boolean integerOnly, Locale... locales) throws NumberFormatException {
        value = StringUtils.trimToNull(value);
        if (value == null) return null;

        // ignore leading plus sign
        if (value.startsWith("+"))
            value = StringUtils.trimToNull(value.substring(1));

        // remove any spaces
        value = StringUtils.replace(value, StringUtils.SPACE, StringUtils.EMPTY);

        if (ArrayUtils.isEmpty(locales))
            locales = new Locale[]{Locale.getDefault()};

        for (Locale locale : locales) {
            // check, if the value is completely numeric for the locale
            if (!isNumeric(value, locale)) continue;
            NumberFormat format = NumberFormat.getNumberInstance(locale);
            try {
                format.setMinimumFractionDigits(0);
                format.setParseIntegerOnly(integerOnly);
                format.setGroupingUsed(value.indexOf(DecimalFormatSymbols.getInstance(locale).getGroupingSeparator()) > -1);
                return format.parse(value);
            } catch (ParseException ex) {
            }
        }
        throw new NumberFormatException("The provided value '" + value + "' is not numeric!");
    }
public static Number parseNumber ( String value , boolean integerOnly , Locale ... locales ) throws NumberFormatException { value = StringUtils . trimToNull ( value ) ; if ( value == null ) return null ; // ignore leading plus sign if ( value . startsWith ( "+" ) ) value = StringUtils . trimToNull ( value . substring ( 1 ) ) ; // remove any spaces value = StringUtils . replace ( value , StringUtils . SPACE , StringUtils . EMPTY ) ; if ( ArrayUtils . isEmpty ( locales ) ) locales = new Locale [ ] { Locale . getDefault ( ) } ; for ( Locale locale : locales ) { // check, if the value is completely numeric for the locale if ( ! isNumeric ( value , locale ) ) continue ; NumberFormat format = NumberFormat . getNumberInstance ( locale ) ; try { format . setMinimumFractionDigits ( 0 ) ; format . setParseIntegerOnly ( integerOnly ) ; format . setGroupingUsed ( value . indexOf ( DecimalFormatSymbols . getInstance ( locale ) . getGroupingSeparator ( ) ) > - 1 ) ; return format . parse ( value ) ; } catch ( ParseException ex ) { } } throw new NumberFormatException ( "The provided value '" + value + "' is not numeric!" ) ; }
Convert a string value into a number.

@param value       the string value to convert
@param integerOnly wether only the integer part of the value is parsed
@param locales     locales, against which the value is parsed
@return numeric value for the string
@throws NumberFormatException if the string is not a valid number
Convert a string value into a number .