can someone helpe me , is there any good way of validating an input date string.
Even after setting lenient as false in SimpleDateFormat , for the patter mm/dd/yyyy its validating this date fine : 10/02/23a0 or 10/2/23445
I have seen apache common's date validator , but in version 1.4 or less it doenst not have validdate method with leneincy option.
It's not a bug in the parsing, it's a design feature*. The reason behind this is that you can parse one String using multiple formats. For instance, first a Date, then some String, then a number, then another String, then another format. By using a ParsePosition object you can chain this formatting.
Fortunately, that very same class can help us out here. By using the alternative parse method, you can get the location where parsing stopped:
* Well, maybe it is a bug. The parse(String) method uses the above parse method internally, but it only throws a ParseException if the Date is null. It doesn't have the comparison between the parse position and the String length. It perhaps should have it, but I doubt it will be added after all this time. That's why I have a utility method for parsing strictly like the above.