title: Java getter and setter for a date field
body: <p>I am beginning Java and I have been ask to write a class myDate. Such a class has fields for year, month and day.</p>
  
  <p>I should use the following syntax to set the date:</p>
  
  <pre><code>setDate(long timeElapsed)
  </code></pre>
  
  <p>I know that I can do the following:</p>
  
  <pre><code>Date tempDate = new Date();
  long lngDate = tempDate.getTime();
  System.out.println("lngDate: " + lngDate);
  </code></pre>
  
  <p>How do I calculate the "long timeElapsed" parameter from a given year, month and day?</p>
  
  <p>Now, I should use GregorianCalendar to display the date, for which I have done the following:</p>
  
  <pre><code>GregorianCalendar cal = new GregorianCalendar(year, month, day);
  System.out.println("Year: " + cal.YEAR);
  System.out.println("Month: " + cal.MONTH);
  System.out.println("Day: " + cal.DAY_OF_MONTH);
  </code></pre>
  
  <p>But the results I get are as follow:</p>
  
  <pre><code>Year: 1
  Month: 2
  Day: 5
  </code></pre>
  
  <p>How can I use GregorianCalendar to display a date in myDate class? I have been working on this issue for a while without success.</p>
  
  <p>I will very much appreciate your feedback.</p>
  
  <p>Respectfully,<br>
  Jorge Maldonado</p>