Here you can find the source of roundTwoDecimals(double d)
public static String roundTwoDecimals(double d)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String roundTwoDecimals(double d) { DecimalFormat twoDForm = new DecimalFormat("#.##"); return twoDForm.format(d); }/*www . j a v a 2 s . c om*/ public static String roundTwoDecimals(float f) { DecimalFormat twoDForm = new DecimalFormat("#.##"); return twoDForm.format(f); } }