For example ... Calculating 8/6 will have a periodic tithe with a value equal to 1.333333 ... But I only want to show the user only 2 digits after the comma, that is, 1.33. How can I do this?
For example ... Calculating 8/6 will have a periodic tithe with a value equal to 1.333333 ... But I only want to show the user only 2 digits after the comma, that is, 1.33. How can I do this?
I already found the answer.
Just use DecimalFormat
, like this:
double x = 1.3333;
DefimalFormat df = new DecimalFormat("0,##");
df.format(x);