Try this one. Find out your region (Locale) and use that locale specific DecimalFormat
.
For more info have a look at NumberFormat#getNumberInstance(Locale).
double no = 123456.7890;
for (Locale locale : Locale.getAvailableLocales()) {
NumberFormat numberFormat = DecimalFormat.getNumberInstance(locale);
System.out.println("========================================");
System.out.println(locale.getDisplayCountry() + " - " + locale.toString());
System.out.println(numberFormat.format(no));
DecimalFormat decimalFormat = (DecimalFormat) NumberFormat.getNumberInstance(locale);
String numberPattern = decimalFormat.toLocalizedPattern();
System.out.println(numberPattern);
}
output:
========================================
Malaysia - ms_MY
123,456.789
#,##0.###
========================================
Qatar - ar_QA
123,456.789
#,##0.###;#,##0.###-
========================================
Iceland - is_IS
123.456,789
#.##0,###
========================================
Finland - fi_FI
123 456,789
# ##0,###
========================================
- pl
123 456,789
# ##0,###
========================================
Malta - en_MT
123,456.789
#,##0.###
and so on...