Parsing a String into date with pattern:"dd/MM/yyyy"
Posted
by kawtousse
on Stack Overflow
See other posts from Stack Overflow
or by kawtousse
Published on 2010-04-29T08:05:14Z
Indexed on
2010/04/29
8:57 UTC
Read the original article
Hit count: 285
Hi, I want to insert a date having this format MM/dd/YYYY for example:04/29/2010 to 29/04/2010 to be inserted into mysql database in a field typed Date. So i have this code:
String dateimput=request.getParameter("datepicker");
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date dt = null;
try
{
dt = df.parse(dateimput);
System.out.println("date imput is:" +dt);
}
catch (ParseException e)
{
e.printStackTrace();
}
but it gives me those error:
1-date imput is:Fri May 04 00:00:00 CEST 2012 (it is not the correct value that have been entered).
2-dismatching with mysql date type.
I can not detect the error exactly. Please help.
© Stack Overflow or respective owner