df.parse("12/12/20151") was executing fine. It should not be parsed as per the date format. I have tried with df.setLenient(false) and df.setLenient(true). But it was parsing successfully.
Do I need to manually check for the length of the string?
Is that an api issue?
Well, you might want your code to still work in 10000 years time!
I suspect that could be the point. 20151 is a valid year.
Lester Burnham
Rancher
Joined: Oct 14, 2008
Posts: 1337
posted
0
You seem to assume that "yyyy" means that the year should have 4 digits - that is not the case. Read the javadocs of the SimpleDateFormat class to find out how the pattern is interpreted for years.
Mahadevan
Greenhorn
Joined: Oct 05, 2005
Posts: 6
posted
0
Thanks for your info. I have refered the Javadoc and if yyyy in pattern means any number.