Im getting a String from my Jsp from a input
<form method=POST action="ResultServlet">
Enter date
<input type="datetime" name="StartEvent" >
<input type="datetime" name="StopEvent" >
<input type="submit" name="PostThis" value="Show" class="f-halfbutton">
And i try to format or parse it into date so i can send it to my database.
String stopDateStr = request.getParameter("StopEvent");
SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssZ");
Date to = new Date();
try {
to = sdf.parse(stopDateStr);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(from);
System.out.println(to );
When i print the string i get the correct format like this 2015-05-19 15:19:12
i want to keep the same format just change it to date instead of string. but after my format my string or date that it should be now looks like this Mon Jan 19 15:19:12 CET 2015
i tried to read here on solutions but nothing seem to work for me.
i've been reading on oracle on the simpledateformatter to know what letters to use to get numbers but doesnt seem to work.
anyone got a good solutions for this?