This site requires JavaScript, please enable it in your browser!
Greenfoot back
tRapkIng
tRapkIng wrote ...

2016/4/21

how can I get a money format?

tRapkIng tRapkIng

2016/4/21

#
I have everything set up already but I just need the double variables to have this context "$0.00" instead of 0.0......
danpost danpost

2016/4/22

#
You can use (import first) the java.text.DecimalFormat class and then use the following lines of code:
DecimalFormat formatter = new DecimalFormat("$###,##0.00");
String moneyText = formatter.format(<? amount ?>));
supplying the 'amount' (money value).
You need to login to post a reply.