I am using BigDecimal to get some price values. Requirement is something like this, what ever the value we fetch from database, the displayed valued should have 2 decimal points.
Eg:
fetched value is 1 - should be displayed as 1.00
fetched value is 1.7823 - should be displayed as 1.78
I am using setScale(2, BigDecimal.ROUND_HALF_UP)
but still some places, if the data from DB is a whole number then the same is being displayed !!
I mean if the value is 0 from DB its displayed as 0 only. I want that to be displayed as 0.00
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…