I am trying to convert the xmlGregorianCalendar to Date. But the output is reducing the date by a day. The below is the code I use - xmlGregorianCalendar is passed as 2019-04-02Z , But when the below line is executed its returns the date as - Mon Apr 01 19:00:00 CDT 2019
private Date formatDate(XMLGregorianCalendar xmlGregorianCalendar) {
if(null != xmlGregorianCalendar ) {
return xmlGregorianCalendar.toGregorianCalendar().getTime();
}
return null;
}
Not sure what am I doing wrong.