title: How to test java.sql.Timestamp is within a few milliseconds?
body: <p>I'm writing a unit test, and due to some weird conversion problem between SQL server dates and <code>java.util.Date</code>, when I test my actual and expected dates, they are consistently 0-2ms off.</p>
  
  <p>How can I assert that these dates are within just a few milliseconds of eachother?</p>
  
  <pre><code>def currentTime = new Date()
  
  dao.recordLogin(currentTime)
  
  def actual = dao.getLastLogin()
  
  expect: actual == new java.sql.Timestamp(currentTime.time)
  
  /*
    actual == new Timestamp(currentTime.time)
    |      |  |             |           |
    |      |  |             |           1381332920392
    |      |  |             Wed Oct 09 11:35:20 EDT 2013
    |      |  2013-10-09 11:35:20.392
    |      false
    2013-10-09 11:35:20.393
  */
  </code></pre>
  
  <p>Tried to keep the code example relatively simple. Lemme know if you want more.</p>