Java BigDecimal Negate negate(BigDecimal amount)

Here you can find the source of negate(BigDecimal amount)

Description

negate

License

Open Source License

Declaration

public static BigDecimal negate(BigDecimal amount) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    public static BigDecimal negate(BigDecimal amount) {
        return !isZeroOrNull(amount) ? amount.negate() : amount;
    }/*from   w  w w  . jav  a 2  s  . c o  m*/

    public static Boolean isZeroOrNull(BigDecimal amount) {
        return amount == null || BigDecimal.ZERO.compareTo(amount) == 0;
    }

    public static int compareTo(Object value1, Object value2) {
        return new BigDecimal(String.valueOf(value1)).compareTo(new BigDecimal(String.valueOf(value2)));
    }
}

Related

  1. negate(BigDecimal decimal)
  2. negate(final BigDecimal value)
  3. negateIfTrue(final boolean condition, final BigDecimal value)
  4. negation(BigDecimal bigDecimal)