I came across a piece of code as follows:
Timestamp expiryDate = Timestamp.valueOf(dateStr + " " + "23:59:59.000");
Here, dateStr is the string entered by the user in the form, in the format yyyy-mm-dd. Now the behavior of Timestamp.valueOf is such that it converts non-existent dates to the corresponding correct dates. Say June 31, 2008 to July 01, 2008.
How can I check in Java if the dateStr string is actually a valid date? I know that I can manually check, but what I would like to know is that any of these methods are already available for this.
source share