Java – Removing “Z” part from XMLGregorianCalender


When I do like below,

GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
calendar.setTime(startTime);  // startTime Date

I get Output like 2015-04-15T11:04:30.000Z.

I want it to be like 2015-04-15T11:04:30.000.

Is there a way to achieve this?

Best Solution

Accepted answer or my Java seems to be outdated because I received this error: The method newXMLGregorianCalendar(String) in the type DatatypeFactory is not applicable for the arguments (SimpleDateFormat)

and I didn't want to extend, so I solved it by removing timezone: