tags:

views:

108

answers:

1
  String dateimput=request.getParameter("datepicker");
System.out.printl("datepicker:" +dateimput);   
 DateFormat df = new SimpleDateFormat("MM/dd/yyyy");

    Date dt = null;
    try
    {
        dt = df.parse(dateimput);
        System.out.println("date imput is:" +dt);

    } catch (ParseException e)
   {
        e.printStackTrace();

  }

*datepicker:04/29/2010 (value I currently selected from datepicker). *the field in database is typed date. 1-date imput is:Thu Apr 29 00:00:00 CEST 2010 and in database level it is inserted like that 01/01/0001 00:00:00

A: 

Your Java code will work fine.

04/29/2010 will give you a date object with the correct time/date set.

You said the problem is during the Database insert, so you should tell us the used database and post the code you are using for the insert.

echox
I use MYSQL DataBaseSo this is my query:String query = "Insert into dailytimesheet(trackingDate,activity,projectCode) values ("+df.format(dt)+", \""+activity+",\""+projet+"\")";
kawtousse