I am trying to do date validation. When the user enters something like: 2552533 Jan 2012 1340001 this gets parsed as: Wed Sep 03 07:41:00 EDT 9000. Here is my code:
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy kkmm");
...
Date test;
try {
test = sdf.parse(dateString);
} catch (Exception e) {
...
Here dateString is a string that I’m trying to parse into a date. If the string isn’t a valid date, like: 552533 Jan 2012 1340001, I was hoping for an error to be thrown. What am I doing wrong?
Try this (before parsing the actual date):
See also: