Java Utililty Methods BigDecimal Parse

List of utility methods to do BigDecimal Parse

Description

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

Method

BigDecimalparseBigDecimal(String number, BigDecimal defValue)
parse Big Decimal
try {
    if (number != null && !number.isEmpty())
        return new BigDecimal(number);
} catch (Exception e) {
    e.printStackTrace();
return defValue;
BigDecimalparseBigDecimalForEntity(String bigDecimalString)
parse Big Decimal For Entity
if (bigDecimalString == null) {
    return null;
bigDecimalString = bigDecimalString.trim();
bigDecimalString = bigDecimalString.replaceAll(",", "");
if (bigDecimalString.length() < 1) {
    return null;
return new BigDecimal(bigDecimalString);
BigDecimalparseTo_BigDecimal(String s)
parse T Big Decimal
if (isBlank(s)) {
    return null;
return new BigDecimal(s);
BigDecimalparseTo_BigDecimal(String s)
parse T Big Decimal
if (s == null) {
    return null;
try {
    return new BigDecimal(s);
} catch (NumberFormatException nfe) {
    if (nfe.getMessage() == null) {
        throw new NumberFormatException("Incorrect input \"" + s + "\" for BigDecimal.");
...
BigDecimalparseToBigDecimal(Object value)
parse To Big Decimal
if (value == null) {
    return null;
if (value instanceof Byte) {
    return new BigDecimal((Byte) value);
} else if (value instanceof Double) {
    return new BigDecimal((Double) value);
} else if (value instanceof Float) {
...
BigDecimalstring2BigDecimal(String valor)
string Big Decimal
BigDecimal valorBig = BigDecimal.ZERO;
Locale brasil = new Locale("pt", "BR");
DecimalFormat df = new DecimalFormat("#,##0.00", new DecimalFormatSymbols(brasil));
df.setParseBigDecimal(true);
valorBig = (BigDecimal) df.parse(valor);
return valorBig;
BigDecimalstringToBigDecimal(String numeroStr)
string To Big Decimal
DecimalFormatSymbols symbols = new DecimalFormatSymbols(new Locale("pt", "BR"));
symbols.setDecimalSeparator(',');
symbols.setCurrencySymbol("");
DecimalFormat decimalFormat = new DecimalFormat("#,##0.0#", symbols);
decimalFormat.setDecimalFormatSymbols(symbols);
decimalFormat.setGroupingUsed(false);
decimalFormat.setParseBigDecimal(true);
decimalFormat.setMinimumFractionDigits(2);
...
FloatstrToFloat(String text, int decimals)
Parses a string to produce a Float with a number of fraction digits.
try {
    return new Float(getFormat(decimals).parse(text).floatValue());
} catch (Exception except) {
    except.printStackTrace();
    return null;
StringtoDecimalString(String str, int decimal)
to Decimal String
if (null == str) {
    return "";
return toDecimalString(Double.valueOf(str.trim()), decimal);