Here you can find the source of rounded(BigDecimal amount)
Parameter | Description |
---|---|
amount | the amount to round, not null |
public static BigDecimal rounded(BigDecimal amount)
//package com.java2s; /**//from ww w . j a va2 s. com * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ import java.math.BigDecimal; import java.math.RoundingMode; public class Main { /** * The number of decimals to retain. */ public static final int DECIMALS = 2; /** * The rounding mode. */ public static final RoundingMode ROUNDING_MODE = RoundingMode.HALF_EVEN; /** * Rounds an amount to two decimal places. * * @param amount the amount to round, not null * @return the rounded amount, not null */ public static BigDecimal rounded(BigDecimal amount) { return amount.setScale(DECIMALS, ROUNDING_MODE); } }