title: Program getting executed indefinetly after comparing with system time
body: <p>Explanation -
  StartTime is being fetched from a table (EX- 2014-07-25 12:00:00)</p>
  
  <p>Startwork() does the insert function </p>
  
  <pre><code>do {
      long time = startTime.getTime() + (((59 * 60) + 59) * 1000);
      Date endTime = new Date(time);
      System.out.println("INFO:   Calling startWork(" + startTime + "," + endTime + ")");
      startWork(startTime, endTime);
      startTime = new Date(startTime.getTime() + (60 * 60 * 1000));
      systemHour = new Date(new Date().getYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), 0, 0);
      String stringToUpdateLastProcessedTime = "update meter_thread set last_processed_time='" + sdf.format(startTime) + "' where name='Gateway Park Occupancy' ";
      mysqlStatement.executeUpdate(stringToUpdateLastProcessedTime);
  }
  while (startTime.getTime() != systemHour.getTime());
  System.out.println("INFO:   Switching to live mode");
  Thread.sleep(1000 * 55 * 60);
  </code></pre>
  
  <p>The problem I am encountering is that, the program is getting executed for future dates if the starttime fetched from the table is (ex -2014-07-25 12:00:00) and the current system time is (ex-2014-07-25 12:20:00) instead of switching to live mode.</p>
  
  <p>Please help in where I am going wrong.</p>