Java BigDecimal Create getBigDecimal(String value)

Here you can find the source of getBigDecimal(String value)

Description

get Big Decimal

License

Open Source License

Declaration

public static BigDecimal getBigDecimal(String value) 

Method Source Code


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

import java.math.BigDecimal;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static BigDecimal getBigDecimal(String value) {
        BigDecimal result = null;
        if (value != null) {
            try {
                result = BigDecimal.valueOf(Double.valueOf(value));
            } catch (Exception ignored) {
            }/*  ww  w . j a va  2s.  c o m*/
        }
        return result;
    }

    public static BigDecimal getBigDecimal(String value, String pattern) {
        BigDecimal result = null;
        assert value != null : "[DSU] invalid value : " + value;

        if (value != null) {
            Matcher m = Pattern.compile(pattern).matcher(value.trim());
            if (m.matches()) {
                result = getBigDecimal(m.group(1));

            }
        }
        return result;
    }
}

Related

  1. getBigDecimal(Object o)
  2. getBigDecimal(Object v, BigDecimal defaultValue)
  3. getBigDecimal(Object value)
  4. getBigDecimal(Object value)
  5. getBigDecimal(String aInput)
  6. getBigDecimalArrayFromByteArray(byte[] buf)
  7. getBigDecimalByObject(Object obj)
  8. getBigDecimalFrom(double value)
  9. getBigDecimalFromByteArray(byte[] bytes, int start, int length, int scale)