How to convert the input date 2019-03-04T18: 55: 05.591 + 03: 00 to the timestamp to save to the oracle database?
I use simpleDateFormat to parse the date 2019-03-04T18: 55: 05.591 + 03: 00 and get the Date.
public class DateAdapter extends XmlAdapter<String, Date> { private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); @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); } } }
But, there is a case when they send a date without specifying milliseconds and I get a parsing error. 2019-03-04T18: 55: 05 + 03: 00
How can this be avoided?