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

inttoInt(String string, int defaultValue)
to Int
if (string != null && !string.isEmpty()) {
    return Integer.valueOf(string);
return defaultValue;
inttoInt(String string, int defaultValue)
to Int
if (isEmpty(string)) {
    return defaultValue;
try {
    return Integer.parseInt(string);
} catch (NumberFormatException ex) {
    return defaultValue;
inttoInt(String text, int defaultValue)
to Int
if (text == null || text.isEmpty()) {
    return defaultValue;
int ret;
try {
    ret = (int) Double.parseDouble(text);
} catch (Exception e) {
    return defaultValue;
...
inttoInt(String v, int def)
Converts specified string to int.
if (v == null)
    return def;
try {
    return Integer.valueOf(v).intValue();
} catch (NumberFormatException e) {
    return def;
inttoInt(String value)
Extends the Integer#valueOf(String) method, in removing the leading and trailing whitespace.
if (value == null) {
    throw new NumberFormatException("Int value not defined.");
value = value.trim();
return Integer.parseInt(value);
inttoInt(String value)
Helper function for referencing integers from templates.
return Integer.valueOf(value);
inttoInt(String value)
Converts a string into an int.
if (value == null) {
    return 0;
if (value.startsWith("0x")) {
    return Integer.parseInt(value.substring(2), 16);
if (value.endsWith("b")) {
    return Integer.parseInt(value.substring(0, value.length() - 1), 2);
...
inttoInt(String value)
to Int
if (!isBinary(value))
    return 0;
if (value.length() > 31)
    return Integer.MAX_VALUE;
return Integer.parseInt(value, 2);
inttoInt(String value)
Gets an int representation of a string value.
try {
    if (value != null) {
        return Integer.parseInt(value);
} catch (Exception ex) {
return 0;
inttoInt(String value, int _default)
to Int
if (value == null || value.length() == 0)
    return _default;
return Integer.valueOf(value);