Here you can find the source of getBigDecimalByObject(Object obj)
Parameter | Description |
---|---|
obj | the obj |
public static BigDecimal getBigDecimalByObject(Object obj)
//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; } } }