title: Find difference between two time in java
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/625433/how-to-convert-milliseconds-to-x-mins-x-seconds-in-java">How to convert Milliseconds to “X mins, x seconds” in Java?</a><br>
    <a href="https://stackoverflow.com/questions/1555262/calculating-the-difference-between-two-java-date-instances">Calculating the Difference Between Two Java Date Instances</a>  </p>
  </blockquote>
  
  
  
  <p>I have a function like this:</p>
  
  <pre><code> public String setDateAndTime(int h, int m, int s,int amPm) {
      TimeZone nst = TimeZone.getTimeZone("GMT+5:45");
      Calendar calendar1 = new GregorianCalendar(nst);
      Date currentTime1 = new Date();
      calendar1.setTime(currentTime1);
  
  
      calendar1.set(Calendar.HOUR, h);
      calendar1.set(Calendar.MINUTE, m);
      calendar1.set(Calendar.SECOND, s);
      calendar1.set(Calendar.YEAR, calendar1.get(Calendar.YEAR));
      calendar1.set(Calendar.MONTH, calendar1.get(Calendar.MONTH));
      calendar1.set(Calendar.DAY_OF_MONTH, calendar1.get(Calendar.DAY_OF_MONTH));
      calendar1.set(Calendar.AM_PM, amPm);
  
  
      DateFormat formatter = new SimpleDateFormat("hh:mm:ss a");
      String date = formatter.format(calendar1.getTime());
  
      return date;
  }
  </code></pre>
  
  <p>Through this function i created two dates(String) </p>
  
  <pre><code>String s1=setDateAndTime(12,00,00,1);//12:00:00 PM
  String s2=setDateAndTime(3,15,45,0);//3:15:45 AM
  </code></pre>
  
  <p>Now how to find to find difference between s1 and s2, i also need the hours, minutes and second lefts, so that i can do further processing. </p>