title: how to get minutes difference between two time in android
body: <pre><code>public int difftime(String string, String string2) {
          int hours;
          int min = 0;
          int days;
          long difference ;
          try {
              SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
              Date date1 = simpleDateFormat.parse("08:00 AM");
              Date date2 = simpleDateFormat.parse("04:00 PM");
  
               difference = date2.getTime() - date1.getTime();
               days = (int) (difference / (1000 * 60 * 60 * 24));
              hours = (int) ((difference - (1000 * 60 * 60 * 24 * days)) / (1000 * 60 * 60));
               min = (int) (difference - (1000 * 60 * 60 * 24 * days) - (1000 * 60 * 60 * hours))
                      / (1000 * 60);
              hours = (hours &lt; 0 ? -hours : hours);
              Log.i("======= Hours", " :: " + hours);
              return min;
          } catch (ParseException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          return min;
      }
  </code></pre>
  
  <p>This is my function to get time difference in the form of minutes but it give always zero. I don't know where i did mistake please tell me where am doing mistake. <strong>I want result in the form of minutes.</strong> </p>