Java BigDecimal safeAddBD(BigDecimal bd1, BigDecimal bd2)

Here you can find the source of safeAddBD(BigDecimal bd1, BigDecimal bd2)

Description

safe Add BD

License

LGPL

Declaration

public static BigDecimal safeAddBD(BigDecimal bd1, BigDecimal bd2) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.math.BigDecimal;

import static java.math.BigDecimal.*;

public class Main {
    public static BigDecimal safeAddBD(BigDecimal bd1, BigDecimal bd2) {
        if (bd1 == null && bd2 == null) {
            return ZERO;
        } else if (bd2 == null) {
            return bd1;
        } else if (bd1 == null) {
            return bd2;
        } else {// w w w  . ja v a 2 s .co  m
            return bd1.add(bd2);
        }
    }
}

Related

  1. removeTrailingZeros(final BigDecimal bd)
  2. removeVAT(int priceInCents, BigDecimal vat)
  3. reverseSign(BigDecimal decimal)
  4. rundeKaufmaennisch( BigDecimal bigDecimal, int stellen)
  5. safeAdd(BigDecimal left, BigDecimal right)
  6. safeNull(BigDecimal value)
  7. safeToBigDecimal(Object obj1)
  8. scalarMult(BigDecimal scalar, Vector a)
  9. scale(BigDecimal b1, BigDecimal b2)