I want to show my numbers in money format and separate digits like the example below:
1000 -----> 1,000
10000 -----> 10,000
100000 -----> 100,000
1000000 -----> 1,000,000
Thanks
On the Home tab, click the Dialog Box Launcher next to Number. Tip: You can also press Ctrl+1 to open the Format Cells dialog box. In the Format Cells dialog box, in the Category list, click Currency or Accounting. In the Symbol box, click the currency symbol that you want.
string value = (Convert. ToDecimal(ReturnValue)). ToString("c");
Another approach :
NumberFormat format = NumberFormat.getCurrencyInstance(); format.setMaximumFractionDigits(0); format.setCurrency(Currency.getInstance("EUR")); format.format(1000000);
This way, it's displaying 1 000 000 €
or 1,000,000 €
, depending on device currency's display settings
You need to use a number formatter, like so:
NumberFormat formatter = new DecimalFormat("#,###"); double myNumber = 1000000; String formattedNumber = formatter.format(myNumber); //formattedNumber is equal to 1,000,000
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With