<p>I came across a code snippet like this:</p>

<p><code>Timestamp expiryDate = Timestamp.valueOf(dateStr + " " + "23:59:59.000"); </code></p>

<p>Here dateStr is a string entered by the user in a form, in the format yyyy-mm-dd. Now the behavior of Timestamp.valueOf is such that it converts non-existent dates into appropriate proper dates. Say 31st June 2008 into 01st July 2008. </p>

<p>How can I check in Java if the dateStr string is in fact a valid date ? I know I can manually do the check, but what I would like to know is whether any method is already available to do the same.</p>

Try
SimpleDateFormat
.  You simply set a format such as the one in your example and then call parse on your dateStr.