Java BigDecimal Format formatBigDecimal(String value)

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

Description

Checks if the value can safely be converted to a BigDecimal.

License

Open Source License

Parameter

Parameter Description
value The value validation is being performed on.

Return

validation result

Declaration

public static BigDecimal formatBigDecimal(String value) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    /**// w w  w .java 2 s.  c o  m
     * Checks if the value can safely be converted to a BigDecimal.
     *
     * @param value The value validation is being performed on.
     * @return validation result
     */
    public static BigDecimal formatBigDecimal(String value) {
        if (value == null) {
            return null;
        }

        try {
            return new BigDecimal(value);
        } catch (NumberFormatException e) {
            return null;
        }

    }
}

Related

  1. format2Scale(BigDecimal obj)
  2. format2String(BigDecimal bd)
  3. format_BigDecimal(BigDecimal decimal, Integer scale)
  4. formatBigDecimal(BigDecimal n, int dp)
  5. formatBigDecimal(BigDecimal value, char thousandSep, char decimalPoint, int numDecimals)
  6. formate(BigDecimal amount)
  7. formatMoney(BigDecimal money, int scale, double divisor)
  8. formatQuantity(BigDecimal quantity)
  9. formatRate(BigDecimal rate)