Convert String to date and compare
<p>One of the fields which I extract from a database is a date in string format and I need to convert it into a date type to compare with another date.  </p>

<p>How do I do this please?  Everything I have tried so far gives me an error of <code>java.util.Date cannot be cast to java.sql.Date</code> and this is attempting the following example;</p>

<p><a href="http://stackoverflow.com/questions/6327392/simpledateformat-gives-java-lang-classcastexception-java-util-date.">simpledateformat-gives-java-lang-classcastexception-java-util-date</a> </p>

<p>An example of the date extracted in string format is "2012-10-15 09:00:29.157".  I think the format to declare is <em>yyyy-MM-dd HH:mm:ss.SSS</em> but not sure.</p>

<p>Thanks</p>
