darsheets
darsheets

Reputation: 276

Xmlgregoriancalendar to 'yyyy-MM-dd' while generating XML SOAP request

I have a WSDL of a soap web service. I generated the source files from the WSDL using wsimport command and added it in my java application code.

In the WSDL there is a date field which is of the type XMLGregorianCalendar. The tricky part here is that when the XML is generated, the format is some default format. Here is the part of the XML request.

<NeedDate>2015-04-06-04:00</NeedDate>

As per the requirement, it have to convert it to 'yyyy-MM-dd' format. My question is how to specify the date format to be used during XML generation.

Thanks.

Upvotes: 2

Views: 4193

Answers (1)

bruno.zambiazi
bruno.zambiazi

Reputation: 1482

I'm not sure if I understood correctly your question, but the format of XMLGregorianCalendar depends the way how it was instantiated.

For example, if you create the instance using DatatypeFactory.newInstance().newXMLGregorianCalendarDate([...]), the output value will be in format yyyy-MM-dd.

Another ways to create an instance of XMLGregorianCalendar are:

  • DatatypeFactory.newInstance().newXMLGregorianCalendar([...])
  • DatatypeFactory.newInstance().newXMLGregorianCalendarTime([...])

I hope it helps.

Upvotes: 1

Related Questions