3

Hello everyone and thanks for your time!

Gonna try to get to the point as simple as possible: I have REST and SOAP webservices.

REST has a LocalDate birthdate field in the request model, and SOAP has a XMLGregorianCalendar birthdate field in the request model.

I want to create for example a Student, I send the SOAP Request in SoapUI, the body will have the XMLGregorianCalendar birthdate and that need to be converted to LocalDate to be processed.

It only works with (yyyy-MM-dd), if i type (yyyy/MM/dd) it wont work... it gives me a Unmarshalling Error: yyyy/MM/dd

What I already tried:

student.setBirthdate(LocalDate.parse(studentSOAP.getBirthdate().toXMLFormat()));

student.setBirthdate(studentSOAP.getBirthdate().toGregorianCalendar().toZonedDateTime().toLocalDate());

I even tried to change the field type to String and then use:

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); student.setBirthdate(LocalDate.parse(studentSOAP.getBirthdate(), formatter));

but it says it cannot parse text "yyyy/MM/dd" at index 4

The adapter is out of option too since it doesnt support a large amount of formats...

Tiago Machado
  • 355
  • 7
  • 24

0 Answers0