Java Object NVL NVL(Object obj, String defaultVaue)

Here you can find the source of NVL(Object obj, String defaultVaue)

Description

NVL

License

Open Source License

Declaration

public static String NVL(Object obj, String defaultVaue) 

Method Source Code

//package com.java2s;

public class Main {

    public static String NVL(Object obj) {
        if (obj != null)
            return obj.toString();
        else//from  ww w.  ja  v  a  2  s.c  om
            return "";
    }

    public static String NVL(Object obj, String defaultVaue) {
        if (obj != null)
            return obj.toString();
        else
            return defaultVaue;
    }

    public static int NVL(Object obj, int defaultVaue) {
        if (obj != null) {
            try {
                return Integer.parseInt(obj.toString());
            } catch (NumberFormatException e) {
                return defaultVaue;
            }
        } else
            return defaultVaue;
    }

    public static double NVL(Object obj, double defaultVaue) {
        if (obj != null) {
            try {
                return Double.parseDouble(obj.toString());
            } catch (NumberFormatException e) {
                return defaultVaue;
            }
        } else
            return defaultVaue;
    }
}

Related

  1. nvl(Integer value, Number valueWhenNull)
  2. NVL(Long l)
  3. nvl(Object a, Object b, Object c)
  4. nvl(Object arg0, Object arg1)
  5. nvl(Object inputObject, Object defaultObject)
  6. nvl(Object objInput, Object objOutput)
  7. nvl(Object source, Object alernative)
  8. NVL(Object str)
  9. nvl(Object value, Object substituteWhenNull)