Here you can find the source of safeAddBD(BigDecimal bd1, BigDecimal bd2)
public static BigDecimal safeAddBD(BigDecimal bd1, BigDecimal bd2)
//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); } } }