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
  • 373
  • 2
  • 6
  • 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
  • 195,030
  • 44
  • 313
  • 345
0

You can use this code

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