Here you can find the source of roundTwoDecimals(double d)
public static double roundTwoDecimals(double d)
//package com.java2s; import java.text.DecimalFormat; public class Main { public static double roundTwoDecimals(double d) { DecimalFormat twoDForm = new DecimalFormat("#.##"); return Double.valueOf(twoDForm.format(d)); }/*from w w w .jav a 2 s.c om*/ }