title: from XMLGregorianCalendar to Date/Calendar adds extra time/unwanted
body: <p>I’m developing a client to a web service which exposes (.wsdl) contract,  which requires yyyy-MM-dd format for 1 on the request parameters , however auto generated POJOS based on the .wsdl create the date attribute as Type  XMLGregorianCalendar.</p>
  
  <hr>
  
  <p><strong>My issue is NOT converting to or from XMLGregorianCalendar see my utility below:</strong></p>
  
  <pre><code>public static XMLGregorianCalendar toXMLGregorianCalendar(Calendar c){
   GregorianCalendar gc = new GregorianCalendar();
   gc.setTimeInMillis(c.getTimeInMillis());
   XMLGregorianCalendar xc= null;
  try {
      xc = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
  } catch (DatatypeConfigurationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
   return xc;
  }
  </code></pre>
  
  <hr>
  
  <p><strong>My issue is going from XMLGregorianCalendar to Date/Calendar adds  extra time/unwanted data  to my yyyy-MM-dd when calling calendar.getTime();</strong>  </p>
  
  <p>In a particular code segment I need to go from XMLGregorianCalendar to Date</p>
  
  <pre><code>if (repairOrderType.getCloseDate() != null) {
  
                  LOG.debug("ServiceHistoryMapper, processRepairOrders() , repairOrderType.getCloseDate() BEFORE:"
                          + repairOrderType.getCloseDate());
                  String date = repairOrderType.getCloseDate().getYear() + "-"
                          + repairOrderType.getCloseDate().getMonth() + "-"
                          + repairOrderType.getCloseDate().getDay();
  
                  //Approach #1, trying to remove hour,minute,sec values by calendar.clear() method , not successful 
                  Calendar calendar = Calendar.getInstance();
                  calendar.set(repairOrderType.getCloseDate().getYear(),
                          repairOrderType.getCloseDate().getMonth(),
                          repairOrderType.getCloseDate().getDay());
                  calendar.clear(Calendar.HOUR);
                  calendar.clear(Calendar.MINUTE);
                  calendar.clear(Calendar.SECOND);
                  calendar.clear(Calendar.MILLISECOND);
  
  
  
                  /*Approach#2 , trying to remove hour,minute,sec values using SimpleDateFormat ,
                   * also not successful. SimpleDateFormat or DateFormat are use to format String output NOT remove internal data
                   *
                  DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
                  Calendar calendar = formatter.getCalendar();
                  calendar.set(repairOrderType.getCloseDate().getYear(),
                  repairOrderType.getCloseDate().getMonth(),
                  repairOrderType.getCloseDate().getDay());
                  */
  
                  LOG.debug("ServiceHistoryMapper, processRepairOrders() , repairOrderType.getCloseDate() AFTER:"
                          + calendar.getTime());
                  repairOrder.setCloseDate(calendar.getTime());
  
              }
  </code></pre>
  
  <p>Output:</p>
  
  <p>27-Nov-2012 18:10:39.743 DEBUG com.tms.owners.integration.nsh.mapping.ServiceHistoryMapper - ServiceHistoryMapper, processRepairOrders() , repairOrderType.getCloseDate() <strong>BEFORE:2012-04-30</strong></p>
  
  <p>27-Nov-2012 18:10:51.413 DEBUG com.tms.owners.integration.nsh.mapping.ServiceHistoryMapper - ServiceHistoryMapper, processRepairOrders() , repairOrderType.getCloseDate() AFTER:Wed <strong>May 30 18:00:00 PDT 2012</strong></p>
  
  <p>As you can see above BEFORE date is BEFORE:2012-04-30 and AFTER date is <strong>May 30 18:00:00 PDT 2012</strong> with unwanted hours "18:00:00 PDT".</p>
  
  <hr>
  
  <p>Below is my actual request XML sent to the service:</p>
  
  <pre><code>&lt;S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;S:Body&gt;
          &lt;ns4:VehicleServiceHistoryDetails
              xmlns="urn:tms.toyota.com/Components" xmlns:ns2="urn://esb.ari.xxxxxx.com/2008/12/10/schemas/common/Customer"
              xmlns:ns3="urn:incentives.ari.xxxxxx.com/StandardHeader"
              xmlns:ns4="urn://esb.ari.xxxxxx.com/2008/12/10/schemas/History"
              xmlns:ns5="http://ice.ari.xxxxxx.com/EMF" xmlns:ns6="urn:ari.xxxxxx.com/rtmheader"&gt;
              &lt;ns5:ApplicationArea&gt;
                  &lt;ns5:CreationDateTime&gt;2012-11-27T18:11:23.071-08:00
                  &lt;/ns5:CreationDateTime&gt;
                  &lt;ns5:Sender /&gt;
                  &lt;ns5:UserArea /&gt;
              &lt;/ns5:ApplicationArea&gt;
              &lt;ns4:VehicleServiceHistoryDataArea&gt;
                  &lt;ns4:VehicleServiceHistoryHeader&gt;
                      &lt;ns3:TimeStamp&gt;2012-11-27T18:11:23.071-08:00&lt;/ns3:TimeStamp&gt;
                      &lt;ns3:SourceSystem&gt;TOO&lt;/ns3:SourceSystem&gt;
                      &lt;ns4:SourceKey&gt;TOY1TWXE&lt;/ns4:SourceKey&gt;
                  &lt;/ns4:VehicleServiceHistoryHeader&gt;
                  &lt;ns4:VehicleServiceHistory&gt;
                      &lt;ns4:VIN&gt;XXXXXXXXXXXXXXXX&lt;/ns4:VIN&gt;
                      &lt;ns4:RepairOrder&gt;
                          &lt;ns2:RepairOrderDealer&gt;
                              &lt;DealerNumber&gt;29059&lt;/DealerNumber&gt;
                          &lt;/ns2:RepairOrderDealer&gt;
                          &lt;ns2:RepairOrderNumber&gt;0088745&lt;/ns2:RepairOrderNumber&gt;
                          &lt;ns2:CloseDate&gt;2012-05-30-07:00&lt;/ns2:CloseDate&gt;
                      &lt;/ns4:RepairOrder&gt;
                  &lt;/ns4:VehicleServiceHistory&gt;
              &lt;/ns4:VehicleServiceHistoryDataArea&gt;
          &lt;/ns4:VehicleServiceHistoryDetails&gt;
      &lt;/S:Body&gt;
  &lt;/S:Envelope&gt;
  </code></pre>
  
  <p>You can see in the request xml in the 2012-05-30-07:00 that extra "-07:00" data is added i just want  2012-05-30.</p>
  
  <p>Thanks </p>