title: How do I convert a java.sql.Date object into a GregorianCalendar?
body: <p>I thought I'd be able to create a <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/GregorianCalendar.html"><code>GregorianCalendar</code></a> using the constructor that takes the year, month, and day, but I can't reliably get those fields from an instance of the <a href="http://docs.oracle.com/javase/6/docs/api/java/sql/Date.html"><code>java.sql.Date</code></a> class.  The methods that get those values from <code>java.sql.Date</code> are deprecated, and the following code shows why they can't be used:</p>
  
  <pre><code>import java.sql.Date;
  import java.util.Calendar;
  import java.util.GregorianCalendar;
  
  public class DateTester {
  
      public static void main(String[] args) {
          Date date = Date.valueOf("2011-12-25");
          System.out.println("Year: " + date.getYear());
          System.out.println("Month: " + date.getMonth());
          System.out.println("Day: " + date.getDate());
          System.out.println(date);
  
          Calendar cal = new GregorianCalendar(date.getYear(), date.getMonth(), date.getDate());
          System.out.println(cal.getTime());
      }
  }
  </code></pre>
  
  <p>Here's the output, showing that the month and year are not returned correctly from the deprecated <code>getYear()</code> and <code>getMonth()</code> methods of <code>Date</code>:</p>
  
  <blockquote>
    <p>Year: 111<br>
    Month: 11<br>
    Day: 25<br>
    2011-12-25<br>
    Thu Dec 25 00:00:00 EST 111  </p>
  </blockquote>
  
  <p>Since I can't use the constructor that I tried above, and there's no <code>GregorianCalendar</code> constructor that just takes a <code>Date</code>, how can I convert a <code>java.sql.Date</code> object into a <code>GregorianCalendar</code>?</p>