Java BigDecimal Parse isBigDecimal(String value)

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

Description

<p>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 boolean isBigDecimal(String value) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    /**/*w w  w  .ja  v  a  2 s.  co  m*/
     * &ltp&gtChecks if the value can safely be converted to a BigDecimal.</p>
     *
     * @param value The value validation is being performed on.
     * @return validation result
     */
    public static boolean isBigDecimal(String value) {
        return (formatBigDecimal(value) != null);
    }

    /**
     * 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. isBigDecimal(final Object value)
  2. isBigDecimal(Number n)
  3. isBigDecimal(Object obj)
  4. isBigDecimal(Object v)
  5. isBigDecimal(String str)
  6. isBigDecimalAssignable(String javaDataType)
  7. isBigDecimalType(Class type)
  8. isInteger(BigDecimal decimal)
  9. isInteger(BigDecimal inValue)