Java Code Examples for java.math.BigDecimal#ROUND_HALF_UP

The following examples show how to use java.math.BigDecimal#ROUND_HALF_UP . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: java-platform   File: MallSetting.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置精度
 * 
 * @param amount
 *            数值
 * @return 数值
 */
public BigDecimal setScale(BigDecimal amount) {
	if (amount == null) {
		return null;
	}
	int roundingMode;
	if (getPriceRoundType() == RoundType.roundUp) {
		roundingMode = BigDecimal.ROUND_UP;
	} else if (getPriceRoundType() == RoundType.roundDown) {
		roundingMode = BigDecimal.ROUND_DOWN;
	} else {
		roundingMode = BigDecimal.ROUND_HALF_UP;
	}
	return amount.setScale(getPriceScale(), roundingMode);
}
 
Example 2
/**
 * Constructs an unnamed function. Make sure to set a Name or function initialisation will fail.
 */
public ItemAvgFunction() {
  sum = new Sequence<BigDecimal>();
  itemCount = new Sequence<BigDecimal>();
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}
 
Example 3
/**
 * Constructs a new function.
 * <p/>
 * Initially the function has no name...be sure to assign one before using the function.
 */
public TotalGroupSumQuotientFunction() {
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
  dividendFunction = new TotalGroupSumFunction();
  divisorFunction = new TotalGroupSumFunction();
}
 
Example 4
/**
 * Creates a new ItemPercentageFunction.
 */
public ItemPercentageFunction() {
  totalSumFunction = new TotalGroupSumFunction();
  totalSumFunction.setName( "total" );
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
  scaleToHundred = true;
}
 
Example 5
@Override
public int getRounding(String currencyCode) {
    return "JPY".equalsIgnoreCase(currencyCode) ? BigDecimal.ROUND_DOWN : BigDecimal.ROUND_HALF_UP;
}
 
Example 6
/**
 * Default constructor.
 */
public ColumnDivisionExpression() {
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}
 
Example 7
/**
 * Default Constructor.
 */
public ColumnAverageExpression() {
  this.returnInfinity = true; // for backward compatiblity.
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}
 
Example 8
/**
 * Creates a new expression. The fields used by the expression are defined using properties named '0', '1', ... 'N'.
 * These fields should contain {@link Number} instances.
 */
public AverageExpression() {
  this.fieldList = new ArrayList();
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}
 
Example 9
/**
 * Constructs a new function.
 * <P>
 * Initially the function has no name...be sure to assign one before using the function.
 */
public PercentageExpression() {
  scale = 14;
  roundingMode = BigDecimal.ROUND_HALF_UP;
}