title: Trying to format a String to date using Servlet
body: <p>Im getting a String from my Jsp from a input</p>
  
  <pre><code>&lt;form method=POST action="ResultServlet"&gt;
                  Enter date
                  &lt;input type="datetime" name="StartEvent" &gt;
                  &lt;input type="datetime" name="StopEvent" &gt;
  
  
             &lt;input type="submit" name="PostThis" value="Show" class="f-halfbutton"&gt;
  </code></pre>
  
  <p>And i try to format or parse it into date so i can send it to my database.</p>
  
  <pre><code>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 );
  </code></pre>
  
  <p>When i print the string i get the correct format like this 2015-05-19 15:19:12</p>
  
  <p>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</p>
  
  <p>i tried to read here on solutions but nothing seem to work for me.</p>
  
  <p>i've been reading on oracle on the simpledateformatter to know what letters to use to get numbers but doesnt seem to work.</p>
  
  <p>anyone got a good solutions for this?</p>