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 86 times
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ı
- 3,877
- 2
- 16
- 33