Java BigDecimal Create getDecimal(String number, BigDecimal def)

Here you can find the source of getDecimal(String number, BigDecimal def)

Description

Parse the given string into a big decimal if possible otherwise return the specified default.

License

Open Source License

Declaration

public static BigDecimal getDecimal(String number, BigDecimal def) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;

public class Main {
    /**//from  w w  w  .  j a v  a 2 s .  c  o m
     * Parse the given string into a big decimal if possible otherwise return
     * the specified default.
     */
    public static BigDecimal getDecimal(String number, BigDecimal def) {
        try {
            return new BigDecimal(number);
        } catch (Exception e) {
            return def;
        }
    }
}

Related

  1. getBigDecimalOrNull(Object value)
  2. getBigDecimalValue(Object o)
  3. getDecimal(double a)
  4. getDecimal(Object[] data, int ordinal)
  5. getDecimal(String clusive, int[] currentDecimal)
  6. getDecimalCoords(Integer degrees, Integer minutes, Integer seconds)
  7. getDecimalValue(String value, Object franctionDigits)
  8. getDecimalValues(String[] values, String dataType)
  9. nullToBigDecimalZero(final Object obj)