title: How to convert String to Date without knowing the format?
body: <p>I have a problem. I am trying to convert some strings to date, and I don't know the format the date is arriving.</p>
  
  <p>It might come as <code>yyyy.mm.dd hh:mm:ss</code> or <code>MM.dd.yy hh:mm:ss</code> and so on.</p>
  
  <p>How can I convert these strings to Date?
  I tried this:</p>
  
  <pre><code>DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
  Date d = (Date)formatter.parse(someDate);
  </code></pre>
  
  <p>But when I printed out someDate it printed out like this: 2010-08-05 12:42:48.638 CEST which means <code>yyyy.mm.dd hh:mm:ss</code>, however when I ran the above code, the date object now became <code>Sat Jan 31 00:42:48 CET 11</code> which is strange to say the least.</p>
  
  <p>Any ideas how I can correctly format strings to date?</p>