title: Right way to convert XMLGregorianCalendar to GregorianCalendar
body: <p>I have 2 classes. First contains Calendar field and Integer field (tz offset). Second contains XmlGregorianCalendar field. I want to compare date from firs class to date from second.</p>
  
  <pre><code>Calendar cal1 = (Calendar) SerializationUtils.clone(firstClass.getDepartureDatetime());
  cal1.add(Calendar.MINUTE, -firstClass.getDepartureTzOffset());
  
  GregorianCalendar cal2 = secondClass.getDepartureDateTime().toGregorianCalendar();
  cal2.add(Calendar.MINUTE, -secondClass.getDepartureDateTime().getTimezone());
  
  if (LOGGER.isDebugEnabled()) {
                  LOGGER.debug(" - Second  [" + DateFormat.getDateTimeInstance().format(cal2.getTime()) + "]");
                  LOGGER.debug(" - First [" + DateFormat.getDateTimeInstance().format(cal1.getTime()) + "]");
  }
  </code></pre>
  
  <p>I've set equal dates (Nov 19, 9:00 AM GMT+1) in that classes.</p>
  
  <p>Depending on the system TZ it shows different results (in GMT TZ):</p>
  
  <p>Debian Lenny, TZ is CET:</p>
  
  <pre><code>Second  [Nov 19, 2011 7:00:00 AM] - wrong!
  First [Nov 19, 2011 8:00:00 AM] -right!
  </code></pre>
  
  <p>Win7, TZ is GMT+3:</p>
  
  <pre><code>Second  [Nov 19, 2011 8:30:00 AM] - wrong!
  First [Nov 19, 2011 8:00:00 AM] -right!
  </code></pre>
  
  <p>What I'm doing wrong?</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>1st and 2nd classes:</p>
  
  <pre><code>public class FirstClass implements Serializable {
      private static final long serialVersionUID = -1150341618306402800L;
  
      private Calendar departureDatetime;
  
      private Integer departureTzOffset;
  
      public Calendar getDepartureDatetime() {
          return departureDatetime;
      }
  
      public void setDepartureDatetime(Calendar departureDatetime) {
          this.departureDatetime = departureDatetime;
      }
  
      public Integer getDepartureTzOffset() {
          return departureTzOffset;
      }
  
      public void setDepartureTzOffset(Integer departureTzOffset) {
          this.departureTzOffset = departureTzOffset;
      }
  }
  
  public class SecondClass implements Serializable
  {
  
      private final static long serialVersionUID = 12345L;
  
      protected XMLGregorianCalendar departureDateTime;
  
      public XMLGregorianCalendar getDepartureDateTime() {
          return departureDateTime;
      }
  
      public void setDepartureDateTime(XMLGregorianCalendar value) {
          this.departureDateTime = value;
      }
  }
  </code></pre>
  
  <p>SerializationUtils is an org.apache.commons.lang.SerializationUtils from Apache commons-lang lib.</p>