Ver Mensaje Individual
  #7 (permalink)  
Antiguo 23/01/2012, 04:40
elpre
 
Fecha de Ingreso: junio-2011
Mensajes: 151
Antigüedad: 12 años, 10 meses
Puntos: 2
Respuesta: tipo fecha de jsp a servlet

Ya lo he entendido. Pero sigo teniendo un problema (intentaré explicarlo detallado)
La fecha que cojo en el JavaServlet desde el formulario jsp tiene que ser String:
Código PHP:
String fecha=(req.getParameter("fecha")==null?"":req.getParameter("fecha")); 
Eso tiene que ser así, porque de otra forma no sale.
Tengo una función que hace insert y a ese insert le paso la fecha que tiene que ser tipo Date, por lo que la variable fecha la convierto a Date y así a la funcion insert le paso la variable Date:
Código PHP:
SimpleDateFormat simple= new SimpleDateFormat("yyyyMMdd"); 
        
Date data null;
        try {
            
data simple.parse(fecha);
        } catch (
ParseException e) {
            
// TODO Auto-generated catch block
            
e.printStackTrace();
        } 
Luego ya en el insert le he puesto que me haga el str_to_date().
El problema viene al hacer el SimpleDateFormat() que si pongo "yyyyMMdd" me coge null y si pongo "yyyy-MM-dd", me coge 'Wed Jan 23 00:00:00 CET 2012'.
Es decir el problema es que tengo que conseguir que al hacer insert me haga el pase

Última edición por elpre; 23/01/2012 a las 05:18