developer155
Programmer
Hi, I need to formatt a string (the string reperesents a price and it is stored in the database with one zero after the whole part, like 30.0). I need it to have 2 zeros (30.00). here is what I am doing:
String cost;
cost=database.getCost();//this ghets cost from db
String pattern="00.00";
DecimalFormat myFormatter = new DecimalFormat(pattern);
cost = myFormatter.format(cost);
I am getting an error that I am passing an object and that is incorrect. I see that I am passign a String object into format function, but what shoudl I do? Any ideas how to fix this or how to do what I need to do in some other way?
thanks!
String cost;
cost=database.getCost();//this ghets cost from db
String pattern="00.00";
DecimalFormat myFormatter = new DecimalFormat(pattern);
cost = myFormatter.format(cost);
I am getting an error that I am passing an object and that is incorrect. I see that I am passign a String object into format function, but what shoudl I do? Any ideas how to fix this or how to do what I need to do in some other way?
thanks!