Java Utililty Methods Null Value Convert

List of utility methods to do Null Value Convert

Description

The list of methods to do Null Value Convert are organized into topic(s).

Method

booleannull2Boolean(Object s)
null Boolean
boolean v = false;
if (s != null)
    try {
        v = Boolean.parseBoolean(s.toString());
    } catch (Exception localException) {
return v;
Stringnull2default(final String str, final String def)
nulldefault
return (str == null || str.length() <= 0) ? def : str;
Stringnull2dots(Object s)
nulldots
if (s == null || s.toString().length() == 0)
    return "...";
return s.toString();
doublenull2Double(Object s)
null Double
double v = 0.0D;
if (s != null)
    try {
        v = Double.parseDouble(null2String(s));
    } catch (Exception localException) {
return v;
doublenull2Double(Object s, double defValue)
null Double
if (s != null) {
    try {
        return Double.parseDouble(s.toString());
    } catch (Exception e) {
return defValue;
Objectnull2Empty(Object obj)
null Empty
if (obj == null) {
    return "";
return obj;
Stringnull2empty(Object s)
nullempty
if (s == null) {
    return "";
if (s instanceof String) {
    return (String) s;
return s.toString();
Stringnull2empty(String str)
nullempty
return str == null ? "" : str;
Stringnull2emptyString(String value)
nullempty String
if (value != null) {
    return value;
return "";
intnull2Int(Object object, int def)
null Int
if (object != null) {
    try {
        return Integer.parseInt(object.toString());
    } catch (Exception e) {
return def;