title: Checking an array to see if it has dates which have already past
body: <p>I have an array of task objects. The tasks have due dates. The array is ordered from the earliest date to the latest. I have made a method which is supposed to return the position of the last task that is before today. In other words it has to check whether each task is before today and once it gets to the task that is after today stop and return the position of the last task before today. If the first task is after to day it should return -1. However the method is not functioning as expected. Could I get a reason as to why this is not working:</p>
  
  <pre><code>public int overdue() {
      int i = -1;
      this.sort();
      Date Today = new Date();
      DateFormat dateFormat = new SimpleDateFormat("dd MMMMM yyyy");
      String todayString = dateFormat.format(Today);
      try {
          Today = new SimpleDateFormat("dd MMMM yyyy").parse(todayString);
      } catch (ParseException ex) {
          Logger.getLogger(HomeworkDiary.class.getName()).log(Level.SEVERE, null, ex);
      }
      while (Today.after(diary[i+1].getDue_Date().getTime()) == true) {
              i++;
      }
      return i;
  }
  </code></pre>