Java BigDecimal to convertToBigDecimal(String val)

Here you can find the source of convertToBigDecimal(String val)

Description

convert To Big Decimal

License

Apache License

Declaration

public static BigDecimal convertToBigDecimal(String val) throws NumberFormatException 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    public static BigDecimal convertToBigDecimal(String val) throws NumberFormatException {
        BigDecimal returnValue = new BigDecimal(0.00);
        if (val == null || val.trim().equals("")) {
            return returnValue;
        }/*from  w w  w  .j a  v  a 2  s  .  c o  m*/

        val = val.replace(",", "");
        val = val.replace("$", "");

        returnValue = new BigDecimal(val.trim());
        return returnValue;
    }
}

Related

  1. convertSecondsToMillis(BigDecimal seconds)
  2. convertStringToBigDecimal(String strValue)
  3. convertToBigDecimal(final Object o)
  4. convertToBigDecimal(Object sourceValue)
  5. convertToBigDecimal(String s)
  6. convertToBigDecimal(String value)
  7. convertToBigDecimal(String value)
  8. convertToFen(BigDecimal num1)
  9. decimalToBytes(BigDecimal v, byte[] result, final int offset, int length)