Java Null Value Convert convertNullToLong(Object orgStr, Long convertStr)

Here you can find the source of convertNullToLong(Object orgStr, Long convertStr)

Description

: convertNulg

License

Apache License

Parameter

Parameter Description

Exception

Parameter Description

Return

Long

Declaration

public static Long convertNullToLong(Object orgStr, Long convertStr) 

Method Source Code

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

public class Main {

    public static Long convertNullToLong(Object orgStr, Long convertStr) {
        if (orgStr == null || Long.parseLong(orgStr.toString()) == 0) {
            return convertStr;
        } else {//from w w w.j a v a 2  s . c  o  m
            return Long.valueOf(orgStr.toString());
        }
    }

    public static long convertNullTolong(Object orgStr, long convertStr) {
        if (orgStr == null || Long.parseLong(orgStr.toString()) == 0) {
            return convertStr;
        } else {
            return Long.parseLong(orgStr.toString());
        }
    }

    public static String toString(Object[] objArr) {
        if (objArr == null) {
            return null;
        }

        StringBuffer buf = new StringBuffer("[");
        for (int i = 0; i < objArr.length; i++) {
            buf.append((i > 0 ? "," : "") + objArr[i]);
        }
        buf.append("]");
        return buf.toString();
    }

    public static String toString(Object obj) {
        if (obj instanceof String) {
            return "\"" + obj + "\"";
        }
        if (obj instanceof Object[]) {
            return toString((Object[]) obj);
        } else {
            return String.valueOf(obj);
        }
    }
}

Related

  1. convertNullToEmptyString(Object raw)
  2. convertNullToEmptyString(String s)
  3. convertNullToEmptyString(String value)
  4. convertNullToFalse(Boolean b)
  5. convertNullToInteger(Object orgStr, int convertStr)
  6. convertNullToOne(final Object value)
  7. convertNullToSolrValue(String fieldName)
  8. convertNullToString(final String str)
  9. convertNullValue(final Class convertType)