title: How can I compare two Calendar dates?
body: <p>I have a Java problem where I need to check if an item has expired. This is supposed to check if the item is at least x (x is an integer and can be set to any integer value) months old. </p>
  
  <p>Just to reclarify Supposing I have a pack of eggs, I want to check if it has been 1 months since I added them (<code>dateAdded</code>).</p>
  
  <p>I wrote a simple comparison but it doesn't seem to give the correct response.  Here is the code.</p>
  
  <pre><code>public Boolean isEndOfLine() {
      Calendar today = Calendar.getInstance();
      if(today.compareTo(dateAdded) &gt;= END_OF_LINE) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>The value of end of line is an integer 12 i.e 12 months.</p>