title: Calculating difference between two java.sql.Timestamp shows negative value
body: <p>I am calculating the difference between two timestamps which is in the following format</p>
  <blockquote>
  <p>2013-07-22 05:24:24.77</p>
  </blockquote>
  <p>I am using the following method to calculate the difference between two timestamps</p>
  <pre><code>DateFormat sdf = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss.SSS&quot;);
  Date resDate = sdf.parse(responseData.getTimestamp().toString());
  Date reqDate = sdf.parse(requestData.getTimestamp().toString());
  System.out.println(&quot;response--&gt;&quot;+responseData.getTimestamp());
  System.out.println(&quot;request--&gt;&quot;+requestData.getTimestamp());
  System.out.println(&quot;diff--&gt;&quot;+(resDate.getTime()-reqDate.getTime()));
  </code></pre>
  <p>The difference between two timestamps is negative in the following cases. For example</p>
  <blockquote>
  <p>Response date : 2013-07-22 05:24:24.77</p>
  <p>Request date  : 2013-07-22 05:24:24.663</p>
  </blockquote>
  <p>Result is :</p>
  <blockquote>
  <p>diff--&gt;-586</p>
  </blockquote>
  <p>it should subtract something like this <strong>&quot;770-663&quot;</strong> instead it subtracting the timestamp as  <strong>&quot;77-663&quot;</strong>.</p>
  <p>Can anyone please suggest what changes I should make or is there any other way to do it??</p>
  <p>Thanks in advance</p>