I use a lot decimal characters with dot. but they should be written with comma. Is there a way I can change all of them?
Asked
Active
Viewed 375 times
0
-
By the way: https://stackoverflow.com/q/5054132/589259 . OK question goes the other way, but techniques will be identical. Note that this kind of Android functionality is taken from Java, so it is not Android specific. – Maarten Bodewes Jul 10 '20 at 12:38
1 Answers
1
String.format("%,d", number)
or
DecimalFormat formatter = new DecimalFormat("#,###,###");
String yourFormattedString = formatter.format(5000);
or
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(currentLocale);
otherSymbols.setDecimalSeparator(',');
otherSymbols.setGroupingSeparator('.');
DecimalFormat df = new DecimalFormat(formatString, otherSymbols);
currentLocale can be obtained from Locale.getDefault() i.e.:
Locale currentLocale = Locale.getDefault();

Arda Kazancı
- 8,341
- 4
- 28
- 50