Correct string representations of numbers depend on the Locale: "2.5" is a valid number in the US, but not in Germany. The German representation of this number is "2,5". Is there any way in Java to detect that a given string is a valid number with respect to a certain Locale?
var decimal = DecimalFormat.getInstance(Locale.Germany).parse("2.5");
The DecimalFormat just ignores the "." and reads the number as 25, which is not what I need. I need a way to tell that this is not a valid number representation in Germany. How can I get such a test?
The solutions proposed as answers to the question here either ignore the locale altogether, or propose a home-made parsing algorithm which does neither consider the complexities nor the multiple differences in the locales. Is there a library which does that job simple and complete?