Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/05/2011, 09:32
abulon81
 
Fecha de Ingreso: mayo-2010
Mensajes: 99
Antigüedad: 14 años
Puntos: 5
mejora de funcion.

Hi all, You take a look at this friends, I guess this function it's can make improvements.
Código PHP:

System
.out.println(testNum("10.50"));
........
   public static 
int testNum(String numero) {
      
int bol=0;
      
boolean bole=false;
       
int number ;
       
double num ;
       try {
          if(
bole==false)
          {
               
Integer.parseInt(numero);
              
bol=1bole=true;
          }
           
//System.out.println("it's integer");
       
}       
       catch (
NumberFormatException e) {
           
//e.printStackTrace();
       
}
       
finally {
          try {
              if (
bole==false)
              {
                   
Double.parseDouble(numero);
                   
bol=3bole=true;
              }
          }
          
          catch(
NumberFormatException e) {
           
e.printStackTrace();   
          }
          
          
finally {
              return 
bol;
          }
       }
   } 
Hope this helps all of you.