Possible Duplicate:
Parsing numbers safely and locale-sensitively
How can I validate strings containing decimal numbers in a locale-sensitive way? NumberFormat.parse allows too much, and Double.parseDouble works only for English locale. Here is what I tried:
public static void main(String[] args) throws ParseException {
Locale.setDefault(Locale.GERMAN);
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.getDefault());
Number parsed = numberFormat.parse("4,5.6dfhf");
System.out.println("parsed = " + parsed); // prints 4.5 instead of throwing ParseException
double v = Double.parseDouble("3,3"); // throws NumberFormatException, although correct
}