1DecimalFormat df = new DecimalFormat();
2df.setMaximumFractionDigits(2);
3System.out.println(df.format(decimalNumber));
1double test = 12.15;
2DecimalFormat df = new DecimalFormat("#.0");
3System.out.println(df.format(test)); // Console: 12.2
4// # - prints a digit if provided, nothing otherwise
5// . - indicates where to put the decimal seperator
6// 0 - prints a digit if provided, 0 otherwise
1total = (double) 100 / listMember.size();
2DecimalFormat df = new DecimalFormat("#.##");
3String dx = df.format(total);
4total = Double.valueOf(dx);