Here you can find the source of doubleToBigDecimal(double amountAsDouble)
public static BigDecimal doubleToBigDecimal(double amountAsDouble)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static final int DECIMAL_SCALE = 8; public static final RoundingMode ROUNDING_MODE = RoundingMode.HALF_UP; public static BigDecimal doubleToBigDecimal(double amountAsDouble) { return new BigDecimal(amountAsDouble).setScale(DECIMAL_SCALE, ROUNDING_MODE); }/*from w ww . j a v a2s. c om*/ }