Java BigDecimal from toBigDecimal(Number number)

Here you can find the source of toBigDecimal(Number number)

Description

Converts (almost) any number to BigDecimal .

License

Apache License

Parameter

Parameter Description
number original number

Return

same number but of type

Declaration

public static BigDecimal toBigDecimal(Number number) 

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 a2  s .  co m*/
     * Converts (almost) any number to {@linkplain BigDecimal}.
     * 
     * @param number
     *            original number
     * @return same number but of {@linkplain BigDecimal} type
     */
    public static BigDecimal toBigDecimal(Number number) {
        if (number instanceof BigDecimal)
            return (BigDecimal) number;
        return new BigDecimal(number.toString());
    }
}

Related

  1. toBigDecimal(Number n)
  2. toBigDecimal(Number n)
  3. toBigDecimal(Number n)
  4. toBigDecimal(Number n)
  5. toBigDecimal(Number num)
  6. toBigDecimal(Number number)
  7. toBigDecimal(Number number)
  8. toBigDecimal(Number number)
  9. toBigDecimal(Number number, int scale)