I get the following exception
java.lang.NumberFormatException: Invalid int: \"\"
It is happening when you try to store a value into
Generally speaking, exception processing is a good approach for this kind of undesired behavior :
if( obj != null && obj.getTargetWeight() != null ) {
try {
int i = Integer.parseInt( obj.getTargetWeight() );
//do something if target weight is a number
} catch( NumberFormatException ex ) {
//do something if target weight was not a number.
}
}
---edited to precise exception type