Java BigDecimal tryParseBigDecimal(Object val, BigDecimal defaultVal)

Here you can find the source of tryParseBigDecimal(Object val, BigDecimal defaultVal)

Description

try Parse Big Decimal

License

Apache License

Declaration

public static BigDecimal tryParseBigDecimal(Object val, BigDecimal defaultVal) 

Method Source Code

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

import java.math.BigDecimal;

public class Main {
    public static BigDecimal tryParseBigDecimal(Object val, BigDecimal defaultVal) {
        if (val == null)
            return defaultVal;
        if (val instanceof BigDecimal)
            return (BigDecimal) val;
        try {/*from w w w .j a  va2s . co  m*/
            return new BigDecimal(String.valueOf(val));
        } catch (Exception e) {
            return defaultVal;
        }
    }
}

Related

  1. strValueBigDecimal(Number number)
  2. tangent(BigDecimal x)
  3. tanto(BigDecimal r, BigDecimal n)
  4. textToBigDecimal(String amountAsText)
  5. transferDonateAmount2Point(BigDecimal donateAmount)
  6. tryToStoreAsIntegerBigDecimal(Object ob)
  7. tryToStoreAsRealBigDecimal(Object ob)
  8. unformattedFromBigDecimal(BigDecimal n)
  9. unformattedToBigDecimal(String str)