Here you can find the source of formatDoubleNumber(double f)
public static double formatDoubleNumber(double f)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; public class Main { public static double formatDoubleNumber(double f) { BigDecimal b = new BigDecimal(f); return b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); }//from w ww . j a v a 2s .c om }