title: How to compare java.sql.Timestamp and java.util.Date
body: <p>I know java Date was poor designed, but I don't know how until today.</p>
  
  <p>I saved a date to DB and when I get it from DB and compare to original date, it told me it's different!</p>
  
  <p>And I wrote a test which looks strange but it PASSED!</p>
  
  <pre><code>@Test
  public void date_equals() {
      Date now = new Date();
      Timestamp timestamp = new Timestamp(now.getTime());
  
      assertFalse(timestamp.equals(now));
      assertTrue(now.equals(timestamp));
  
      assertTrue(timestamp.compareTo(now) == 0);
      assertFalse(now.compareTo(timestamp) == 0);
  
      assertTrue(timestamp.getTime() == now.getTime());
      assertTrue(now.getTime() == timestamp.getTime());
  }
  </code></pre>
  
  <p>I noticed that java.sql.Timestamp has a little different than Date about nanoseconds which I don't care.</p>
  
  <p>Can anyone told me how to compare this two in best practice?
  I don't want to compare date use getTime() everywhere, is there any common library or other ways to do this?</p>
  
  <p>BTW I'm using JDK 6</p>