Java BigDecimal Normalize normalizeDecimalValue(BigDecimal bigDecimal, int allowedPrecision)

Here you can find the source of normalizeDecimalValue(BigDecimal bigDecimal, int allowedPrecision)

Description

This method will check the digits before dot with the max precision allowed

License

Apache License

Parameter

Parameter Description
bigDecimal a parameter
allowedPrecision precision configured by the user

Declaration

public static BigDecimal normalizeDecimalValue(BigDecimal bigDecimal, int allowedPrecision) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    /**//from  w w w  .  j a v  a  2s  .  co m
     * This method will check the digits before dot with the max precision allowed
     *
     * @param bigDecimal
     * @param allowedPrecision precision configured by the user
     * @return
     */
    public static BigDecimal normalizeDecimalValue(BigDecimal bigDecimal, int allowedPrecision) {
        if (bigDecimal.precision() > allowedPrecision) {
            return null;
        }
        return bigDecimal;
    }
}

Related

  1. normalize(BigDecimal bigDecimal)
  2. normalize(final BigDecimal dec)
  3. normalizePrecision(String precision, BigDecimal... decimals)
  4. normalizeScale(BigDecimal bigDecimal)