Java BigDecimal Value Check isPositive(BigDecimal value)

Here you can find the source of isPositive(BigDecimal value)

Description

is Positive

License

Open Source License

Declaration

public static Boolean isPositive(BigDecimal value) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    public static Boolean isPositive(Integer value) {
        return value != null && value > 0;
    }/*from   www.j a v  a2s  .  com*/

    public static Boolean isPositive(BigDecimal value) {
        return value != null && value.compareTo(BigDecimal.ZERO) > 0;
    }

    public static Boolean isPositive(Object value) {
        return isPositive(forceParseBigDecimal(value));
    }

    public static BigDecimal forceParseBigDecimal(Object value) {
        if (value == null || value.toString().isEmpty()) {
            return new BigDecimal(0);
        } else {
            try {
                Double check = Double.parseDouble(value.toString());
                return new BigDecimal(check);
            } catch (NumberFormatException e) {
                return new BigDecimal(0);
            }
        }
    }

    public static Double parseDouble(Object value) {
        if (value == null || value.toString().isEmpty()) {
            return null;
        } else {
            try {
                return Double.parseDouble(value.toString());
            } catch (NumberFormatException e) {
                return null;
            }
        }
    }
}

Related

  1. isNull(final BigDecimal s)
  2. isNullOrZero(BigDecimal number)
  3. isNullOrZero(BigDecimal value)
  4. isParseableBigDecimal(String string)
  5. isPositive(BigDecimal number)
  6. isPrimeNumber(BigDecimal inBd)
  7. isProfitable(BigDecimal ask, BigDecimal bid, BigDecimal fee, BigDecimal minProfit)
  8. isSameValue(final BigDecimal val1, final BigDecimal val2)
  9. isStrictementNegatif(BigDecimal pNombre)