Java Utililty Methods BigDecimal from String

List of utility methods to do BigDecimal from String

Description

The list of methods to do BigDecimal from String are organized into topic(s).

Method

BigDecimalstring2BigDecimal(String aValue)
string Big Decimal
if (aValue != null && aValue.trim().length() > 0) {
    return new BigDecimal(aValue);
} else {
    return null;
BigDecimalstring2BigDecimal(String s)
string Big Decimal
try {
    if (s == null || "".equals(s.trim())) {
        return null;
    } else {
        return new BigDecimal(s);
} catch (Exception e) {
    return null;
...
BigDecimalstring2BigDecimal(String st)
Konvertiert einen String in einen BigDecimal-Wert mit zwei Nachkommastellen.
BigDecimal result = new BigDecimal(st);
result.setScale(2, BigDecimal.ROUND_HALF_EVEN);
return result;
BigDecimalString2BigDecimal(String str)
String Big Decimal
return BigDecimal.valueOf(Double.parseDouble(str));
BigDecimalstringToBigDecimal(String numberString)
string To Big Decimal
BigDecimal BD;
Double number = Double.parseDouble(numberString);
if (number.doubleValue() == 0.0) {
    BD = BigDecimal.ZERO;
} else {
    BD = new BigDecimal(number);
return BD;
...
BigDecimalstringToBigDecimal(String src, int[] endPos)
A slightly more tolerant version of the BigDecimal constructor - we allow the valid number to be followed by non-numeric characters at the end of the string.
int endIndex = src.length();
while (!Character.isDigit(src.charAt(endIndex - 1))) {
    endIndex--;
BigDecimal value = new BigDecimal(src.substring(0, endIndex));
endPos[0] = endIndex;
return value;
BigDecimalstringToDec(final CharSequence stringValue, final BigDecimal defaultValue)
Converts a string value to its equivalent BigDecimal value.
BigDecimal result;
try {
    result = new BigDecimal(stringToNumericAdjust(stringValue, false));
} catch (final Exception e) {
    result = defaultValue;
return result;