in src/main/java/org/apache/commons/validator/GenericTypeValidator.java [239:261]
public static Double formatDouble(final String value, final Locale locale) {
Double result = null;
if (value != null) {
NumberFormat formatter = null;
if (locale != null) {
formatter = NumberFormat.getInstance(locale);
} else {
formatter = NumberFormat.getInstance(Locale.getDefault());
}
final ParsePosition pos = new ParsePosition(0);
final Number num = formatter.parse(value, pos);
// If there was no error and we used the whole string
if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length() &&
num.doubleValue() >= Double.MAX_VALUE * -1 &&
num.doubleValue() <= Double.MAX_VALUE) {
result = Double.valueOf(num.doubleValue());
}
}
return result;
}