Q:

how to round DecimalFormat in java (android)

I want to round
0.005 to 0.01

im using this code
DecimalFormat df = new DecimalFormat("0.00");

but the answer keeps getting 0.00
I want only 2 digits on the right with rounding if possible
anybody has an idea?

A:

You should add the RoundingMode for the DecimalFormat
double d = 0.005;
DecimalFormat df = new DecimalFormat("0.00");
df.setRoundingMode(RoundingMode.HALF_UP);
System.out.println(df.format(d)); //0.01

