int iValue = new Integer(strValue).intValue();
String str = intObj.toString();
int number = Integer.parseInt(str);
public static Object read(String value, Class type) {
Object ret = value;
if (Integer.TYPE.equals(type)) {
ret = Integer.valueOf(value);
}
if (Byte.TYPE.equals(type)) {
ret = Byte.valueOf(value);
}
if (Short.TYPE.equals(type)) {
ret = Short.valueOf(value);
}
if (Long.TYPE.equals(type)) {
ret = Long.valueOf(value);
}
if (Float.TYPE.equals(type)) {
ret = Float.valueOf(value);
}
if (Double.TYPE.equals(type)) {
ret = Double.valueOf(value);
}
if (Boolean.TYPE.equals(type)) {
ret = Boolean.valueOf(value);
}
if (Character.TYPE.equals(type)) {
ret = value.charAt(0);
}
// TODO others.
return ret;
}
REF:
http://way2java.com/casting-operations/data-type-casting-type-conversion/