java - Add 0 to end if number is like $12.5 -


possible duplicate:
usd currency formatting in java

all- have small problem in app outputs answer after inputs go through equation , rounded 2 decimal places after decimal point. problem if number comes out $12.80 output looks $12.8. want $12.80. not biggest deal in final stages of development , clean nice. here of code:

    float result2 = result / l3;      double data2 = result2;       int decimalplaces2 = 2;     double roundbase2 = math.pow(10, decimalplaces2);     data2 = (double)(math.round(data2 * roundbase2)) / roundbase2;      answer.settext("$" + double.tostring(data2)); 

thanks time!

decimalformat format = new decimalformat("$#"); format.setminimumfractiondigits(2); answer.settext(format.format(data2)); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -