insert a date in mysql database
Posted
by kawtousse
on Stack Overflow
See other posts from Stack Overflow
or by kawtousse
Published on 2010-04-29T11:25:13Z
Indexed on
2010/04/29
11:37 UTC
Read the original article
Hit count: 230
I use a jquery datepicker then i read it in my servlet like that:
String dateimput=request.getParameter("datepicker");//1 then parse it like that:
System.out.println("datepicker:" +dateimput);
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
java.util.Date dt = null;
try
{
dt = df.parse(dateimput);
System.out.println("date imput parssé1 est:" +dt);
System.out.println("date imput parsée2 est:" +df.format(dt));
} catch (ParseException e)
{
e.printStackTrace();
}
and insert query like that:
String query = "Insert into dailytimesheet(trackingDate,activity,projectCode) values ("+df.format(dt)+", \""+activity+"\" ,\""+projet+"\")";
it pass successfully untill now but if i check the record inserted i found the date: 01/01/0001 00:00:00
l've tried to fix it but it still a mess for me.
© Stack Overflow or respective owner