FriedCircuits/FC-USB-Tester-Data-Logger-App — pull request #2 by schuppeste (2014-11-14 18:50:02+00:00)
Title: Locales Numberformat parsing Double

Fix Error with Different Double Values"0,00","0.00"
Fix Parse Errors for Double Conversions Try/Catch

Example:

Locale[] locales = NumberFormat.getAvailableLocales();
double myNumber = -1234.56;
NumberFormat form;
for (int j=0; j<4; ++j) {
System.out.println("FORMAT");
for (int i = 0; i < locales.length; ++i) {
if (locales[i].getCountry().length() == 0) {
continue; // Skip language-only locales
}
System.out.print(locales[i].getDisplayName());
switch (j) {
case 0:
form = NumberFormat.getInstance(locales[i]); break;
case 1:
form = NumberFormat.getIntegerInstance(locales[i]); break;
case 2:
form = NumberFormat.getCurrencyInstance(locales[i]); break;
default:
form = NumberFormat.getPercentInstance(locales[i]); break;
}
if (form instanceof DecimalFormat) {
System.out.print(": " + ((DecimalFormat) form).toPattern());
}
System.out.print(" -> " + form.format(myNumber));
try {
System.out.println(" -> " + form.parse(form.format(myNumber)));
} catch (ParseException e) {}
}
}