To set the thousands separator, say 123,456.78 you must use DecimalFormat :
DecimalFormat df = new DecimalFormat("#,###.00"); System.out.println(df.format(new BigDecimal(123456.75))); System.out.println(df.format(new BigDecimal(123456.00))); System.out.println(df.format(new BigDecimal(123456123456.78)));
Here is the result:
123,456.75 123,456.00 123,456,123,456.78
Although I set the mask to #,###.00 , it successfully formats longer values ββas well. Note that the comma separator (,) as a result depends on your locale. It may just be a space () for the Russian locale.
Jeff_Alieffson Jul 21 '15 at 5:45 2015-07-21 05:45
source share