I am developing a client for a web service that provides (.wsdl) a contract that requires the yyyy-MM-dd format for 1 in the request parameters, however the automatically generated POJOS based on .wsdl creates a date attribute as an XMLGregorianCalendar Type.
My problem is NOT converted to or from XMLGregorianCalendar, see my utility below:
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) {
My problem comes from XMLGregorianCalendar in Date / Calendar adds extra temporary / unwanted data to my yyyy-MM-dd when calling calendar.getTime ();
In a specific code segment, I need to go from XMLGregorianCalendar to date
if (repairOrderType.getCloseDate() != null) { LOG.debug("ServiceHistoryMapper, processRepairOrders() , repairOrderType.getCloseDate() BEFORE:" + repairOrderType.getCloseDate()); String date = repairOrderType.getCloseDate().getYear() + "-" + repairOrderType.getCloseDate().getMonth() + "-" + repairOrderType.getCloseDate().getDay();
Output:
27-November-2012 18: 10: 39.743 DEBUG com.tms.owners.integration.nsh.mapping.ServiceHistoryMapper - ServiceHistoryMapper, processRepairOrders (), repairOrderType.getCloseDate () BEFORE: 2012-04-30
27-Nov-2012 18: 10: 51.413 DEBUG com.tms.owners.integration.nsh.mapping.ServiceHistoryMapper - ServiceHistoryMapper, processRepairOrders (), repairOrderType.getCloseDate () AFTER: Wed May 30 18:00: 00 PDT 2012
As you can see above BEFORE the date before: 2012-04-30 and AFTER the date May 30, 18:00:00 PDT 2012 with the unwanted hours "18:00:00 PDT".
Below is my XML request request sent to the service:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <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"> <ns5:ApplicationArea> <ns5:CreationDateTime>2012-11-27T18:11:23.071-08:00 </ns5:CreationDateTime> <ns5:Sender /> <ns5:UserArea /> </ns5:ApplicationArea> <ns4:VehicleServiceHistoryDataArea> <ns4:VehicleServiceHistoryHeader> <ns3:TimeStamp>2012-11-27T18:11:23.071-08:00</ns3:TimeStamp> <ns3:SourceSystem>TOO</ns3:SourceSystem> <ns4:SourceKey>TOY1TWXE</ns4:SourceKey> </ns4:VehicleServiceHistoryHeader> <ns4:VehicleServiceHistory> <ns4:VIN>XXXXXXXXXXXXXXXX</ns4:VIN> <ns4:RepairOrder> <ns2:RepairOrderDealer> <DealerNumber>29059</DealerNumber> </ns2:RepairOrderDealer> <ns2:RepairOrderNumber>0088745</ns2:RepairOrderNumber> <ns2:CloseDate>2012-05-30-07:00</ns2:CloseDate> </ns4:RepairOrder> </ns4:VehicleServiceHistory> </ns4:VehicleServiceHistoryDataArea> </ns4:VehicleServiceHistoryDetails> </S:Body> </S:Envelope>
You can see in the xml request at 2012-05-30-07: 00 that the additional data "-07: 00" is added, I just want 2012-05-30.
thanks