tags:

views:

18

answers:

1

java.util.date = org.apache.commons.lang.time.DateUtils.parseDate(value, new String[] { "mm/dd/yyyy" });

If you give an invalid date string (e.g. value = 13/02/2000 or value = "12/35/2000"), this didn't result in an error (e.g. 13 as a month is invalid and 35 as a date is invalid). But the above function just moved the appropriate date | month bits and gave a date which was correct. Is there a function which will throw a ParseException in such cases?

+3  A: 

DateUtils.parseDateStrictly(String, String[]) FTW!

bemace
looks like this function is in the newer version of commons-lang, we are still using an older version. thanks
Jason