Parsing a String into date with pattern:"dd/MM/yyyy"
- by kawtousse
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.