When I do like below,
GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
calendar.setTime(startTime); // startTime Date
DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
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?
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:
xmlCalendar.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
If you want to remove only "Z" from XMLGregorianCalendar object just call this method.
xmlDate.setTimezone( DatatypeConstants.FIELD_UNDEFINED )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With