Recommended way to format numbers in a locale aware way?
Solution 1:
Using NumberFormat class:
For English:
NumberFormat nf_us = NumberFormat.getInstance(Locale.US);
String number_us = nf_us.format(1000000);
For German:
NumberFormat nf_ge = NumberFormat.getInstance(Locale.GERMAN);
String number_ge = nf_ge.format(1000000);
Solution 2:
You can use NumberFormat.
Android documentation is quite clear on it.
Solution 3:
You can achieve this with using the NumberFormat class, this also allows you to parse Strings into a local aware number.
NumberFormat formatter = NumberFormat.getInstance(Locale.GERMAN);
String localeFormattedNumber = formatter.format(1000000);