title: How to compare XMLGregorianCalendar with only the Date portion (day, month, year)?
body: <p>I'm developing a webservice integrated with spring-struts web application, in XSD there is a XMLGregorianCalendar type property, let's say the property name is <strong>trxDate</strong>. </p>
  
  <p>In SOAPUI testing application, if I inserted the value of trxDate with: <strong>2013-02-21</strong>, then I sent the soap xml request data and I printed the value in service method with: System.out.println(trxDate) method, the printout result is same as inputted: 2013-02-21.</p>
  
  <p>Now, I'm trying to create a function to compare <strong>trxDate</strong> with current date. I know we can compare it using trxDate.compare(currentDate) method. The problem is I don't how to create XMLGregorianCalendar object set with current date with Date portion only (day, month, and year) to be used for comparing.</p>
  
  <p>I tried with this code:</p>
  
  <pre><code>    GregorianCalendar gc = new GregorianCalendar();
      gc.set(GregorianCalendar.HOUR_OF_DAY, 0);
      gc.set(GregorianCalendar.MINUTE, 0);
      gc.set(GregorianCalendar.SECOND, 0);
      gc.set(GregorianCalendar.MILLISECOND, 0);
  
      XMLGregorianCalendar xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
      System.out.println(xgc);
  </code></pre>
  
  <p>The result is:<br/>
  2013-02-20T00:00:00.000+07:00</p>
  
  <p>But I'm expecting:<br/>
  2013-02-20</p>
  
  <p>If use the date (<strong>xgc</strong>) to compare with <strong>trxDate</strong>:<br/></p>
  
  <pre><code>int result = trxDate.compare(xgc);
  </code></pre>
  
  <p>The result is 2, which means: INDETERMINATE (from DatatypeConstants class). The proper result should be -1, 0, or 1.</p>
  
  <p>So what's wrong with my code?</p>