xsd dateTime loosing timezone information being passed through Websphere ESB via JAX-WS
I'm using JAX-WS (WAS 7) --> Websphere ESB 7 --> JAX-WS (WAS 7), populating a xsd:dateTime field with a timestamp.
Here's the flow:
- WAS - Instantiate Response object
- Populate XMLGregorianCalendar field in POJO [
DatatypeFactory.newInstance().newXMLGregorianCalendar((GregorianCalendar)Calendar.getInstance())
]"2010-11-02T15:35:42.047+13:00"
- Pass response back through ESB
- Examine response in gateway "
2010-11-02T02:35:42.047Z
"
As you can see the NZ timezone info is ignored. The returned XMLGregorianCalendarImpl.timezone=0
, where it was XMLGregorianCalendarImpl.timezone=780
when it was instantiated.
The POJO is generated with the "JAX-WS RI IBM 2.1.1 in JDK 6" as
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MessageControl", namespace = "http://xmlschema.customer.co.nz/generic/Response123", propOrder = {
"messageTrackTrace",
"messageDate",
})
public class PojoClass {
@XmlElement(name = "MessageTrackTrace")
protected String messageTrackTrace;
@XmlElement(name = "MessageDate", required = true)
pro开发者_JS百科tected XMLGregorianCalendar messageDate;
Is this a bug in ESB? Perhaps there is a configuration I can change? Cheers
Thanks for the thought Ryan, I solved it by populating a new XMLGregorianCalendar from a Date.
DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
Date messageDate = pojoClass.getMessageDate().toGregorianCalendar().getTime();
cal.setTime(messageDate);
XMLGregorianCalendar xCal = df.newXMLGregorianCalendar(cal);
pojoClass.setMessageDate(xCal);
This maintains the format I want i.e. 'Pacific/Auckland' timezone.
Cheers
精彩评论