In my response i am getting the value as 80.00000
DecimalFormat df = new DecimalFormat("##.##");
TextField.setText(df.format(Double.parseDouble(custom.getValue())));
My problem is i am getting 80.000, i am doing a parseDouble which will return a primitive double type and i am doing a format to this double to 2 decimals.
Why am i getting 80 instead of 80.00?
I changed my way and tried with this.
TextField.setText(String.format("%2f",Double.parseDouble(custom.getValue())));
Now i am geting 80.000000 instead of 80.00
Should be "%.2f" instead of "%2f"
TextField.setText(String.format("%.2f",Double.parseDouble(custom.getValue())));
you forget to add the .
Why am i getting 80 instead of 80.00?
The first example should be:
DecimalFormat df = new DecimalFormat("##.00");
Otherwise any non significant fractional digits will be suppressed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With