title: How to calculate the time difference and show the result in 00:00 format?
body: <p>How to calculate the time difference and show the result in 00:00 format.
  I can't find the way,how to send the string data into date and how to display the result in the EditText  00:00 format.
  I tried it myself but it shows the error that source not found.
  Below is the code.</p>
  
  <pre><code>public class TimeCalculate extends Activity {
  
  private String mBlock = null;
  private String mBlockoff = null;
  private String mBlockon = null;
  
       Date date1,date2;
       EditText block;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      EditText blockoff = (EditText) findViewById(R.id.blockoff);
      mBlockoff = blockoff.getText().toString();
  
      EditText blockon = (EditText) findViewById(R.id.blockon);
      mBlockon = blockon.getText().toString();
      block = (EditText) findViewById(R.id.block);
      mBlock = getDifference(date1, date2);
  
           date1 = new Date(mBlockoff);
      date2 = new Date(mBlockon);
  
                blockon.addTextChangedListener(new TextWatcher() {
          public void afterTextChanged(Editable s) {
              block = (EditText) findViewById(R.id.block);
              mBlock = getDifference(date1, date2);
              block.setText(mBlock);
          }
  
  }
  
  public static String getDifference(Date startTime, Date endTime) {
      String timeDiff;
      if (startTime == null)
          return "[corrupted]";
      Calendar startDateTime = Calendar.getInstance();
      startDateTime.setTime(startTime);
      Calendar endDateTime = Calendar.getInstance();
      endDateTime.setTime(endTime);
      long milliseconds1 = startDateTime.getTimeInMillis();
      long milliseconds2 = endDateTime.getTimeInMillis();
      long diff = milliseconds2 - milliseconds1;
      long hours = diff / (60 * 60 * 1000);
      long minutes = diff / (60 * 1000);
      minutes = minutes - 60 * hours;
      long seconds = diff / (1000);
  
      timeDiff = hours + ":" + minutes;
      return timeDiff; 
  }
  }
  </code></pre>
  
  <p>My Modified code using SampleDateFormat</p>
  
  <pre><code>SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm");
  
      try {
          date1 = simpleDateFormat.parse(mBlockoff);
      } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      try {
          date2 = simpleDateFormat.parse(mBlockon);
      } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Then I called the method as follow</p>
  
  <pre><code>blockon.addTextChangedListener(new TextWatcher() {
          public void afterTextChanged(Editable s) {
              mBlock = getDifference(date1, date2);
              block.setText(mBlock);
          }
  </code></pre>