temp temp wrote:
What is the best way to convert an object to an Integer  .If casting dosen't 
work?

Object probablyAnInteger = ....;

Integer someInt;
if ( probablyAnInteger == null || probablyAnInteger.equals( "" ) )
{
 someInt = null;
}
else
{
 try
 {
   someInt = new Integer( probablyAnInteger.toString() );
 }
 catch ( NumberFormatException e )
 {
    // definitely not an integer
    someInt = null;
 }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to