I am trying to format double value to one decimal point using below code but it produces two different rounding values.
double d1= 4.55;
double d2= 17.85;
DecimalFormat oneDForm = new DecimalFormat("#.0");
System.out.println(oneDForm.format(d1));
System.out.println(oneDForm.format(d2));
Output: 4.6 17.8 (Expecting 17.9)
But what i wanted roundup by counting up for even decimal 17.85
to 17.9
, how to achieve this?