Here you can find the source of formatNumberDouble(Double amount, int scale)
public static double formatNumberDouble(Double amount, int scale)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { public static double formatNumberDouble(Double amount, int scale) { if (null == amount) amount = 0.00;/*from ww w . j a va 2 s . com*/ BigDecimal b = new BigDecimal(amount).setScale(scale, BigDecimal.ROUND_HALF_UP); return b.doubleValue(); } }