Java BigDecimal Create nullToZero(BigDecimal num)

Here you can find the source of nullToZero(BigDecimal num)

Description

null To Zero

License

LGPL

Declaration

public static BigDecimal nullToZero(BigDecimal num) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    public static BigDecimal nullToZero(BigDecimal num) {
        if (num == null) {
            return new BigDecimal("0");
        }//  w  w  w  .jav a 2  s.  c o  m
        return num;
    }

    public static Long nullToZero(Long num) {
        if (num == null) {
            return new Long("0");
        }
        return num;
    }

    public static BigDecimal nullToZero(String num) {
        if (num == null) {
            return new BigDecimal("0");
        }
        return new BigDecimal(num);
    }

    public static Integer nullToZero(Integer num) {
        if (num == null) {
            return new Integer("0");
        }
        return num;
    }
}

Related

  1. getDecimalCoords(Integer degrees, Integer minutes, Integer seconds)
  2. getDecimalValue(String value, Object franctionDigits)
  3. getDecimalValues(String[] values, String dataType)
  4. nullToBigDecimalZero(final Object obj)
  5. nullToZero(BigDecimal decimal)
  6. toBig(Object o)
  7. toBigDecimal(final Object o)
  8. toBigDecimal(final Object value)
  9. toBigDecimal(Object o)