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

IntegertoInt(Object o)
to Int
if (o == null)
    return new Integer(0);
return Integer.valueOf(o.toString());
inttoInt(Object o, int defaultValue)
to Int
if (o == null)
    return defaultValue;
if (o.getClass() == Integer.class)
    return (Integer) o;
if (o.getClass() == Boolean.class)
    return booleanToInt((Boolean) o);
if (o.getClass() == Byte.class)
    return (int) ((Byte) o).byteValue();
...
inttoInt(Object obj)
This method convert object to int.
int value = 0;
if (obj != null) {
    String objVal = String.valueOf(obj);
    if (objVal.length() > 0) {
        Integer intObj = Integer.parseInt(objVal);
        value = intObj.intValue();
return value;
inttoInt(Object obj)
to Int
return toInt(obj, 0);
inttoInt(Object obj)
to Int
String str = obj != null ? obj.toString().trim() : "";
return "".equals(str) ? 0 : Integer.parseInt(str);
inttoInt(Object obj)
Convert object returned from server to int.
return (int) toLong(obj);
inttoInt(Object obj)
to Int
int a = 0;
try {
    if (obj != null)
        a = Integer.parseInt(obj.toString());
} catch (Exception e) {
return a;
inttoInt(Object obj)
to Int
Integer i = toInteger(obj);
if (i != null) {
    return i.intValue();
return 0;
inttoInt(Object obj)
to Int
int value = 0;
if (obj == null)
    return value;
else {
    Integer intObj = (Integer) obj;
    value = intObj.intValue();
    return value;
inttoInt(Object object)
to Int
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt(object.toString());