title: Java / Android - Calculate difference between timestamps
body: <p>I have a problem figuring out how to calculate the elapsed time between two timestamps (hours, minutes, seconds). This is the result: </p>
  
  <pre><code>String starttime = beginElement.getTimestamp();
  String endtime = element.getTimestamp();
  </code></pre>
  
  <p>I/Start time: 1496258892612</p>
  
  <p>I/End time: 1496258928999</p>
  
  <pre><code>long diffTime = Long.parseLong(endtime) - Long.parseLong(starttime);
  </code></pre>
  
  <p>I/Diff time: 36387</p>
  
  <pre><code>String elapsedtime = new SimpleDateFormat("hh:mm:ss").format(Long.parseLong(String.valueOf(diffTime)));
  </code></pre>
  
  <p>I/Elapsed time: 01:00:36</p>
  
  <p>In fact, the elapsed time is just 36 seconds. It's always one hour less than the result.</p>
  
  <p>How do I fix this strange issue?</p>