de XMLGregorianCalendar Date/Calendrier ajoute plus de temps/indésirables

Je suis le développement d'un client à un service web, qui expose à la (.wsdl) du contrat, ce qui nécessite aaaa-MM-jj pour 1 sur les paramètres de la requête , cependant généré automatiquement POJO basé sur la .wsdl créer de la date de l'attribut Type de XMLGregorianCalendar.


Mon problème n'est PAS de la conversion ou de XMLGregorianCalendar voir mon utilitaire ci-dessous:

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;
}

Mon problème est de passer de la XMLGregorianCalendar Date/Calendrier ajoute plus de temps/de données indésirables de mon aaaa-MM-jj lors de l'appel de calendrier.getTime();

Dans un segment de code j'ai besoin d'aller de XMLGregorianCalendar à Jour

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());

            }

De sortie:

27-Nov-2012 18:10:39.743 DEBUG com.tms.des propriétaires.de l'intégration.nsh.la cartographie.ServiceHistoryMapper - ServiceHistoryMapper, processRepairOrders() , repairOrderType.getCloseDate() AVANT:2012-04-30

27-Nov-2012 18:10:51.413 DEBUG com.tms.des propriétaires.de l'intégration.nsh.la cartographie.ServiceHistoryMapper - ServiceHistoryMapper, processRepairOrders() , repairOrderType.getCloseDate() APRÈS le:Mer 30 Mai-18:00:00 PDT 2012

Comme vous pouvez le voir ci-dessus AVANT la date est antérieure:2012-04-30 et APRÈS la date est 30 Mai-18:00:00 PDT 2012 avec des heures "18:00:00 PDT".


Ci-dessous est ma demande réelle XML envoyé au 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>

Vous pouvez le voir dans la demande de xml dans le 2012-05-30-07:00 extra "-07:00" données est ajouté, je veux juste 2012-05-30.

Grâce

OriginalL'auteur cyber101 | 2012-11-28