Spring + jaxb app.
In essence, there is a Date field.
@XmlElement(name = "TimeCalc") @XmlJavaTypeAdapter(DateAdapter.class) Date TimeCalc; How to write jaxb adapter for date data type?
I have a draft, but not a working one:
public class DateAdapter extends XmlAdapter<String, Date> { private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss:SSS"); @Override public String marshal(Date v) throws Exception { synchronized (dateFormat) { return dateFormat.format(v); } } @Override public Date unmarshal(String v) throws Exception { synchronized (dateFormat) { return dateFormat.parse(v); } } } In variable I try to parse and fold
<TimeCalc>20181016T082849.000 GMT</TimeCalc>