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);
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);
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);
You can use this code
double money=1014.66;
String str_money=String.valueOf(money);
str.replace(',','.');
return str;