Here you can find the source of formatDouble(Double toFormat)
public static BigDecimal formatDouble(Double toFormat)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.RoundingMode; public class Main { private static final Integer SCALE = 2; public static BigDecimal formatDouble(Double toFormat) { BigDecimal currency = new BigDecimal(toFormat); return currency.setScale(SCALE, RoundingMode.DOWN); }/* w ww . j a v a 2 s. c om*/ }