title: convert java.sql.Timestamp to java.sql.Date
body: <p>I have a Timestamp and Date variables and i want to compare it for equality (only date part of course). It was surprise for me that contructor Date(long) saves time part, so this code does not work correct:</p>
  
  <pre><code>date = resultSet.getDate(1);
  timestamp = resultSet.getTimestamp(2);    
  //...
  if (date.equals(new Date (timestamp.getTime())) ...
  </code></pre>
  
  <p>I solve this with code like:</p>
  
  <pre><code>DateFormat dateFormat = new SimpleDateFormat ("yyyyMMdd");
  if (date.equals(dateFormat.parse(dateFormat.format(timestamp)))) ...
  </code></pre>
  
  <p>Or i can convert timestamp to date in sql query, but i need a timestamp representation too. Is there a better way to cut a time part from Timestamp.</p>