title: Best way to compare dates in Android
body: <p>I am trying to compare a date in a String format to the current date. This is how I did it (haven't tested, but should work), but am using deprecated methods. Any good suggestion for an alternative? Thanks.</p>
  
  <p>P.S. I really hate doing Date stuff in Java. There are so many ways to do the same thing, that you really aren't sure which one is the correct one, hence my question here.</p>
  
  <pre><code>String valid_until = "1/1/1990";
  
  Calendar cal = Calendar.getInstance();
  SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy");
  Date strDate = sdf.parse(valid_until);
  
  int year = strDate.getYear(); // this is deprecated
  int month = strDate.getMonth() // this is deprecated
  int day = strDate.getDay(); // this is deprecated       
  
  Calendar validDate = Calendar.getInstance();
  validDate.set(year, month, day);
  
  Calendar currentDate = Calendar.getInstance();
  
  if (currentDate.after(validDate)) {
      catalog_outdated = 1;
  }
  </code></pre>