Java BigDecimal from toBigDecimal(Object n)

Here you can find the source of toBigDecimal(Object n)

Description

to Big Decimal

License

Apache License

Declaration

static final private BigDecimal toBigDecimal(Object n) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    static final private BigDecimal toBigDecimal(Object n) {
        if (n != null && (n instanceof Number)) {
            if (n instanceof Double)
                return BigDecimal.valueOf((Double) n);
            if (n instanceof Integer)
                return BigDecimal.valueOf((Integer) n);
            if (n instanceof Long)
                return BigDecimal.valueOf((Long) n);
            if (n instanceof Short)
                return BigDecimal.valueOf((Short) n);
        }//  ww  w  .  j  a  v  a 2s  .  c  om

        return null;
    }
}

Related

  1. toBigDecimal(Number number)
  2. toBigDecimal(Number number)
  3. toBigDecimal(Number number)
  4. toBigDecimal(Number number, int scale)
  5. toBigDecimal(Number price)
  6. toBigDecimal(Object obj)
  7. toBigDecimal(Object obj)
  8. toBigDecimal(Object obj)
  9. toBigDecimal(Object object)