Ver Mensaje Individual
  #2 (permalink)  
Antiguo 31/03/2011, 14:23
abulon81
 
Fecha de Ingreso: mayo-2010
Mensajes: 99
Antigüedad: 13 años, 11 meses
Puntos: 5
Respuesta: Dar formato a una celda de Excel con POI

Hola puedes hacer esto.....

Código PHP:


  System
.out.println("mes "+mes(fecha("01/11/2011")));
  
  
System.out.println("anio "+anio(fecha("01/11/2011")));

......................................
mas codigo

    
public static String fecha(String dato) { 
            
    
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yy"); 
    
Date fecha null;
    
              
        try { 
                    
            
Date today df.parse(dato);             
            
fecha df.parse(dato);
                
        }
           catch (
ParseException e) { 
              
e.printStackTrace(); 
         }
         
finally {
             return 
fecha.toString();
         }
    } 

    private static 
String mes(String fecha_nac) {     
       
     
     
String reg "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"

     
Pattern fecha Pattern.compile(reg);
     
Matcher m =  fecha.matcher(fecha_nac);
     
String cad="";
     
         if (
m.find()){
              
cad m.group(); 
    
         }
        return 
cad;
      } 

    private static 
String anio(String fecha_nac) {            
     
Pattern fecha Pattern.compile("\\d{4}");

     
Matcher m =  fecha.matcher(fecha_nac);
     
String cad="";
     
         if (
m.find()){
              
cad m.group(); 
    
         }
        return 
cad;
      } 
Los concatenas y tienes tu resultado, I hope this helps. . Saludos.