I've just realized that SimpleDateFormat has an unexpected behavior. I don't know whether I should refer to this as a bug or not, you guys decide.. :D
Try this..
DateFormat df = new SimpleDateFormat ("dd/MM/yyyy");
try {
System.out.println (df.parse("31/11/2004"));
System.out.println (df.parse("-1/-1/-1"));
} catch (ParseException e) { }
In my current implementation, I perform some sanity checking towards this behavior, but am I the only one who has to deal with this?
I've been searching in Google, but I can't seem to find anyone else having the same problem as I do..
Anyway, I'm using JDK 1.4.1_01 for Win2K (just for the record)..
What is the output result, and what did you expected?
ReplyDeleteDo you expect to get ParseException?
Try to add this df.setLenient(false);
Thank You whoever posted comment. The solution to add below line works for me:
ReplyDeletethis df.setLenient(false);
- Thank You