Reputation: 1667
I am using below code to convert 79.00538 to 79.00
val df = DecimalFormat("###.##")
df.roundingMode = RoundingMode.DOWN
val retrunValue= df.format(79.00538)
But it give me 79 instead of 79.00.
What might be the issue ?
Upvotes: 0
Views: 64
Reputation: 6549
Symbol Location Localized? Meaning
-----------------------------------------------------------
0 Number Yes Digit
# Number Yes Digit, zero shows as absent
So #
is a digit, but when it is zero, it will not be displayed.
Use 0
for places that you want displayed even when zero.
So I am assuming you wanted a format like this
val df = DecimalFormat("0.00")
Or possibly a format like this, if you want 0.1234
to display as .12
val df = DecimalFormat("#.00")
Upvotes: 1