I try to get a XMLGregorianCalendar
entry which looks like
"06-09-2022 17:05:28:113319"
.
I call an extern api to get a timestamp in style like below. But I need it to call another api.
For the data structure I use many WSDLs. So I implemented an Dateadapter which will convert the timestamp into something like 2022-09-06T17:07:21.319+02:00
. But it did´t work.
I´m using Java - Springboot.
Dateadapter:
public class DateAdapter extends XmlAdapter<String, XMLGregorianCalendar> {
private static final String DATE_STRING = "dd-MM-yyyy HH:mm:ss:SSSSSSSX";
@Override
public String marshal(XMLGregorianCalendar v) throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_STRING);
return dateFormat.format(v.toGregorianCalendar().getTime());
}
@Override
public XMLGregorianCalendar unmarshal(String v) throws Exception {
GregorianCalendar gregorianCalendar = new GregorianCalendar();
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_STRING);
gregorianCalendar.setTime(dateFormat.parse(v));
return DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
}
}