2

It returns me 1014,66 but i want it returning 1014.66 . Any suggestions?

           double money = 1000;
           double last = money * 1 * 1.04166;
           String gift = String.format("%1$,.2f",last);
Grigoris Loukidis
  • 383
  • 2
  • 7
  • 23

2 Answers2

3

Use the version of the String.format method that takes a Locale, and specify a locale that has a dot for decimal separator instead of a comma. For example, the US locale:

String gift = String.format(Locale.US, "%1$,.2f", last);
Jesper
  • 202,709
  • 46
  • 318
  • 350
0

You can use this code

 double money=1014.66;
 String str_money=String.valueOf(money);
 str.replace(',','.');
 return str;
fonfonx
  • 1,475
  • 21
  • 30