Java Utililty Methods String to Int

List of utility methods to do String to Int

  1. HOME
  2. Java
  3. S
  4. String to Int

Description

The list of methods to do String to Int are organized into topic(s).

Method

int asInt(String number)
as Int
if (number.charAt(0) == '+') 
 number = number.substring(1);
return Integer.parseInt(number);
int asInt(String str)
as Int
try {
 return Integer.valueOf(str);
} catch (NumberFormatException nfex) {
 return Integer.MIN_VALUE;
int asInt(String str)
as Int
if (str != null && str.length() > 0)
 try {
 return Integer.parseInt(str.trim());
 } catch (Exception e) {
return 0;
int asInt(String str, int defaultValue)
as Int
try {
 return Integer.parseInt(str);
} catch (Exception e) {
 return defaultValue;
int asInt(String sval, int dflt)
Convert string to integer.
return (null == sval) ? dflt : Integer.parseInt(sval);
Integer asInt(String value)
Returns the integer corresponding to the given string value .
return asInt(value, null);
Integer asInteger(String param)
as Integer
if (param == null) {
 return null;
if (param instanceof String) {
 return Integer.valueOf(param);
} else {
 throw new IllegalArgumentException("Invalid agrument type. Convertion can be made only from String.");
Integer asInteger(String string)
Converts string to integer
return (string == null) ? null : Integer.valueOf(string);
Integer asInteger(String v)
as Integer
try {
 return (v != null) ? Integer.valueOf(v) : null;
} catch (NumberFormatException ex) {
 return null;
int asInteger(String value)
Converts a String value into a int.
return Integer.parseInt(value);


AltStyle によって変換されたページ (->オリジナル) /