Java BigDecimal Create createBigDecimal(final String value)

Here you can find the source of createBigDecimal(final String value)

Description

This method creates a new big-decimal.

License

Apache License

Parameter

Parameter Description
value is the string representation of the new big-decimal.

Return

the value as a big-decimal.

Declaration

public static BigDecimal createBigDecimal(final String value) 

Method Source Code

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

import java.math.BigDecimal;

import java.math.RoundingMode;

public class Main {
    /**/*www .j  a  v  a  2s . co m*/
     * This is the scale of big-decimal literals.
     */
    public static final int BIG_DECIMAL_SCALE = 32;

    /**
     * This method creates a new big-decimal.
     *
     * <p>
     * This method is used to implement big-decimal literals.
     * </p>
     *
     * @param value is the string representation of the new big-decimal.
     * @return the value as a big-decimal.
     */
    public static BigDecimal createBigDecimal(final String value) {
        return createBigDecimal(new BigDecimal(value));
    }

    /**
     * This method creates a new properly scaled big-decimal from an existing big-decimal.
     *
     * <p>
     * This method is used to implement big-decimal operators.
     * </p>
     *
     * @param value is big-decimal itself.
     * @return the value as a properly scaled big-decimal.
     */
    public static BigDecimal createBigDecimal(final BigDecimal value) {
        return value.setScale(BIG_DECIMAL_SCALE, RoundingMode.HALF_EVEN);
    }
}

Related

  1. bigDecimalFromBytes(byte[] decimalBytes, int scale)
  2. bigDecimalFromString(String s)
  3. bigDecimalValue(final Number number)
  4. bigDecimalValueOf(Number n)
  5. createBigDecimal(double v)
  6. createBigDecimal(Object value)
  7. createBigDecimal(String val)
  8. getBdIgnoreNull(BigDecimal bigDecimalPara)
  9. getBigDecimal(BigDecimal bigDecimal)