title: Getting Time Until a Date in Android
body: <p>I am using a Date and Time Dialog to get a Date and Time for an Event Specifed by the User. That data is the Converted by doing the following:</p>
  
  <pre><code>int yearE = Integer.valueOf(evntDate.split("/")[2]);
  int monthE = Integer.valueOf(evntDate.split("/")[1]);
  int dayE = Integer.valueOf(evntDate.split("/")[0]); 
  int hour = Integer.valueOf(evntTm.split(":")[0]);
  int min = Integer.valueOf(evntTm.split(":")[1]);
  </code></pre>
  
  <p>With the Values of:</p>
  
  <pre><code>eventDate = "3/5/2015";
  eventTime = "13:2";
  </code></pre>
  
  <p>I then get that data and COnvert it into Milliseconds and Store that in the Database:</p>
  
  <pre><code>newCalendar.set(yearE, monthE, dayE,hour, min, 0);
  startTime = newCalendar.getTimeInMillis();
  ...
  </code></pre>
  
  <p>When I load the Info from the Database, I try to calculate the amount of time left until the Specified date. So I do the following:</p>
  
  <pre><code>Long timeL = Long.valueOf(time);
  Calendar eventDay = Calendar.getInstance();
  eventDay.setTimeInMillis(timeL);
  Calendar today = Calendar.getInstance();
  long diff = eventDay.getTimeInMillis() - today.getTimeInMillis();
  
  // CONVERT:
  int seconds = (int) TimeUnit.MILLISECONDS.toSeconds(diff);
  int minutes = (int) TimeUnit.MILLISECONDS.toMinutes(diff);
  int hours = (int) TimeUnit.MILLISECONDS.toHours(diff);
  int days = (int) TimeUnit.MILLISECONDS.toDays(diff);
  ...
  </code></pre>
  
  <p>When I log the above data, the days are usually around 30-32 and the rest of the data is incorrect as well. What am I doing wrong? Or what are some alternatives?</p>