Converting Java.util date to XML date without time zone

java

Solution

You can change the timezone so it is undefined. Undefined fields (within reason) won't be included in the output.

XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
xmlGregorianCalendar.setTimezone( DatatypeConstants.FIELD_UNDEFINED );

Problem

I'm using below code to convert java util date to XML gregorian calendar date, but the conversion is somehow adding the time zone to the date. ``` GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.setTimeInMillis(dte.getTime()); XMLGregorianCalendar xmlGrogerianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar); return xmlGrogerianCalendar; ``` I don't want the time zone to be the part of the date. Can any one point out how can i achieve this?

Original source