Invalid Date Format Error in JAVA
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/226910/how-to-sanity-check-a-date-in-java">How to sanity check a date in java</a>  </p>
</blockquote>



<p>I want to convert a String into Date..with a condition that accepted String format should be only this <code>yyyy/MM/dd-HH:MM:SS</code>.</p>

<p>Date provided in any other format should give error.</p>

<pre><code>try {
    String str_date = "25/09/2012-13:43:20";
    DateFormat formatter;
    Date date;
    formatter = new SimpleDateFormat("yyyy/MM/dd-hh:mm:ss");
    date = (Date) formatter.parse(str_date);
    System.out.println("Today is " + date);
} catch (ParseException e) {
    System.out.println("Exception :" + e);
}
</code></pre>

<p>Since <code>str_date</code> is having format <code>dd/MM/yyyy-hh:mm:ss</code>, which is invalid it should through exception, but it is not throwing any expection.</p>

<p>The output is <code>Today is Mon Mar 05 13:43:20 IST 31</code></p>
