Parsing a string to date gives 01/01/0001 00:00:00

Posted by kawtousse on Stack Overflow See other posts from Stack Overflow or by kawtousse
Published on 2010-04-29T09:35:48Z Indexed on 2010/04/29 9:37 UTC
Read the original article Hit count: 154

Filed under:

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

© Stack Overflow or respective owner

Related posts about parsing