Java Utililty Methods Integer Create

List of utility methods to do Integer Create

Description

The list of methods to do Integer Create are organized into topic(s).

Method

IntegertoInteger(Object val)
to Integer
if (val == null)
    return null;
if (val instanceof Number)
    return Integer.valueOf(((Number) val).intValue());
return Integer.valueOf(val.toString().trim());
IntegertoInteger(Object value)
Convert an Object to an Integer.
if (value == null)
    return null;
if (value instanceof Integer)
    return (Integer) value;
if (value instanceof String) {
    if ("".equals((String) value))
        return null;
    return new Integer((String) value);
...
IntegertoInteger(Object value)
to Integer
return toInteger(value, null);
ObjecttoInteger(Object value)
to Integer
if (value instanceof Number) {
    return ((Number) value).intValue();
if (value instanceof String && !((String) value).isEmpty()) {
    return Integer.valueOf((String) value);
return null;
IntegertoInteger(Object value)
to Integer
if (value == null) {
    return 0;
return Integer.parseInt(value.toString());
IntegertoInteger(Object value)
to Integer
if (value instanceof Integer) {
    return (Integer) value;
} else if (value instanceof Number) {
    return ((Number) value).intValue();
} else if (value instanceof String) {
    try {
        return (int) Double.parseDouble((String) value);
    } catch (NumberFormatException ignored) {
...
IntegertoInteger(Object value)
to Integer
try {
    if (value == null || EMPTY.equals(value)) {
        return null;
    return Integer.valueOf(value.toString());
} catch (Exception e) {
    e.printStackTrace();
    return null;
...
IntegertoInteger(Object value)
to Integer
if (value == null)
    return null; 
if (value instanceof Integer)
    return (Integer) value;
if (value instanceof Number)
    return new Integer(((Number) value).intValue());
String svalue = toString(value);
if (svalue == null)
...
inttoInteger(Object value, int defaultValue)
to Integer
if (value == null) {
    return defaultValue;
} else if (value instanceof Number) {
    return ((Number) value).intValue();
} else { 
    return Integer.parseInt(value.toString());
IntegertoInteger(Object x)
to Integer
if (x == null)
    return null;
if (x instanceof Integer)
    return (Integer) x;
if (x instanceof Long)
    return Integer.valueOf(x.toString());
if (x instanceof String)
    return Integer.valueOf((String) x);
...