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

inttoInteger(long n)
to Integer
if (n < Integer.MIN_VALUE || Integer.MAX_VALUE < n) {
    throw new IllegalArgumentException("value out of range: " + n);
return (int) n;
IntegertoInteger(Number n)
Converts a Number to an Integer.
if (n == null) {
    return null;
return n.intValue();
IntegertoInteger(Number n)
Converts a Number into an Integer if not already such
if (n == null) {
    return null;
} else if (n instanceof Integer) {
    return (Integer) n;
} else {
    return n.intValue();
inttoInteger(Number number)
to overcome Exception occur when Integer, Double or other Number object is null when try to do mathematics operation (+-/*)
return (int) toDouble(number);
inttoInteger(Object _inStrObj)
to Integer
if (_inStrObj == null || _inStrObj.toString().trim().equals("")) {
    return 0;
} else {
    return new Integer(_inStrObj.toString()).intValue();
inttoInteger(Object _value, int _default)
Converts a string to an integer, and if unable to do so, returns the default value
if (_value == null)
    return _default;
else if (_value instanceof Integer)
    return (Integer) _value;
else if (_value instanceof Long)
    return ((Long) _value).intValue();
else if (_value instanceof Double)
    return ((Double) _value).intValue();
...
IntegertoInteger(Object anObj)
Converts given value to Integer.
if (anObj == null)
    return null;
Integer tmpResult = null;
if (anObj instanceof Integer) {
    tmpResult = (Integer) anObj;
} else if (anObj instanceof Number) {
    tmpResult = new Integer(((Number) anObj).intValue());
} else {
...
IntegertoInteger(Object cell)
to Integer
if (cell instanceof Long) {
    return ((Long) cell).intValue();
} else if (cell instanceof Integer) {
    return (Integer) cell;
} else if (cell instanceof String) {
    return Integer.parseInt((String) cell);
} else {
    return null;
...
IntegertoInteger(Object o)
to Integer
if (o == null) {
    return null;
return Integer.valueOf(String.valueOf(o));
IntegertoInteger(Object o)
to Integer
Integer i;
if (o instanceof Integer) {
    i = (Integer) o;
} else {
    try {
        i = Integer.valueOf(o.toString());
    } catch (Exception e) {
        i = null;
...