Here you can find the source of convertToBigDecimal(String value)
Parameter | Description |
---|---|
value | the decimal value as a string |
public static BigDecimal convertToBigDecimal(String value)
//package com.java2s; /**//w ww .ja v a 2 s.com * Copyright (c) 2014-2017 by the respective copyright holders. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.math.BigDecimal; public class Main { /** * Convert a string representing a decimal value into a BigDecimal object * * @param value the decimal value as a string * * @return the BigDecimal object representing the value or null in case of conversion error */ public static BigDecimal convertToBigDecimal(String value) { BigDecimal result = null; if (isValid(value)) { result = new BigDecimal(value.trim()); } return result; } private static boolean isValid(String value) { return (value != null) && !value.isEmpty() && !value.equalsIgnoreCase("N/A") && !value.equalsIgnoreCase("NA") && !value.equals("-") && !value.equals("--"); } }