Java BigDecimal Create getBigDecimalByObject(Object obj)

Here you can find the source of getBigDecimalByObject(Object obj)

Description

Gets the big decimal by object.

License

Apache License

Parameter

Parameter Description
obj the obj

Return

the big decimal by object

Declaration

public static BigDecimal getBigDecimalByObject(Object obj) 

Method Source Code

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

import java.math.BigDecimal;

public class Main {
    /**/* w ww. j a v  a  2 s.c  om*/
     * Gets the big decimal by object.
     * 
     * @param obj
     *            the obj
     * @return the big decimal by object
     */
    public static BigDecimal getBigDecimalByObject(Object obj) {
        if (obj == null) {
            return BigDecimal.valueOf(0.0);
        } else {
            BigDecimal result = null;
            try {
                result = new BigDecimal(String.valueOf(obj));
            } catch (Exception ex) {
                result = BigDecimal.valueOf(0.0);
                ;
            }
            return result;
        }
    }
}

Related

  1. getBigDecimal(Object value)
  2. getBigDecimal(Object value)
  3. getBigDecimal(String aInput)
  4. getBigDecimal(String value)
  5. getBigDecimalArrayFromByteArray(byte[] buf)
  6. getBigDecimalFrom(double value)
  7. getBigDecimalFromByteArray(byte[] bytes, int start, int length, int scale)
  8. getBigDecimalFromPrimitiveTypes(int input, int scale, int precision)
  9. getBigDecimalOrNull(Object value)