Java BigDecimal safeToBigDecimal(Object obj1)

Here you can find the source of safeToBigDecimal(Object obj1)

Description

safe To Big Decimal

License

Open Source License

Parameter

Parameter Description
obj1 Object

Return

BigDecimal

Declaration

public static BigDecimal safeToBigDecimal(Object obj1) 

Method Source Code


//package com.java2s;
/*/*from w  w w .j  a  va 2  s  . c om*/
 * Copyright (C) 2010 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.math.BigDecimal;

public class Main {
    /**
     * @param obj1 Object
     * @return BigDecimal
     */
    public static BigDecimal safeToBigDecimal(Object obj1) {
        BigDecimal result = BigDecimal.ZERO;
        if (obj1 == null) {
            return result;
        }
        try {
            result = new BigDecimal(obj1.toString());
        } catch (Exception ex) {
        }

        return result;
    }
}

Related

  1. reverseSign(BigDecimal decimal)
  2. rundeKaufmaennisch( BigDecimal bigDecimal, int stellen)
  3. safeAdd(BigDecimal left, BigDecimal right)
  4. safeAddBD(BigDecimal bd1, BigDecimal bd2)
  5. safeNull(BigDecimal value)
  6. scalarMult(BigDecimal scalar, Vector a)
  7. scale(BigDecimal b1, BigDecimal b2)
  8. scale2(BigDecimal valor)
  9. scaleCurrency(BigDecimal amount)