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
1double input = 3.14159265359;
2System.out.format("double : %.2f", input); // 3.14
3System.out.println("double : " + String.format("%.2f", input)); // 3.14
1total = (double) 100 / listMember.size();
2DecimalFormat df = new DecimalFormat("#.##");
3String dx = df.format(total);
4total = Double.valueOf(dx);