title: How to set an expiration date in java
body: <p>I am trying to write some code to correctly set an expiration date given a certain date.</p>
  
  <p>For instance this is what i have. </p>
  
  <pre><code>    Date lastSignupDate = m.getLastSignupDate();
      long expirationDate = 0;
      long milliseconds_in_half_year = 15778463000L;
      expirationDate = lastSignupDate.getTime() + milliseconds_in_half_year; 
      Date newDate = new Date(expirationDate);
  </code></pre>
  
  <p>However, say if i the sign up date is on 5/7/2011 the expiration date output i get is on 11/6/2011 which is not exactly half of a year from the given date.  Is there an easier way to do this?</p>