title: Java get the number of seconds between 2 dates
body: <p>I'm trting to send data every 10 seconds , 
  so I'm trying tp use this code I wrote 
  but I think I made a mistake in the converting to seconds?</p>
  
  <pre><code>Calendar Time= Calendar.getInstance();
  Calendar SendDate= Calendar.getInstance();
  
  long upload = TimeBetweenDates(SendTime,Time);
  
  if (upload &gt; 10000) {
      String udp = "OK";
      SendUDP(udp);
      SendTime = Calendar.getInstance();
  }
  
  
  public static long TimeBetweenDates (Calendar Start , Calendar End) {
      long end = End.getTimeInMillis();
      long start = Start.getTimeInMillis();
  
      return TimeUnit.MILLISECONDS.toSeconds(Math.abs(end - start)); 
  }
  </code></pre>