public static Calendar parseXmlDate(String xsDate) throws ParseException {
        try {
            final DatatypeFactory df = DatatypeFactory.newInstance();
            final XMLGregorianCalendar dateTime = df.newXMLGregorianCalendar(xsDate);
            return dateTime.toGregorianCalendar();
        } catch (DatatypeConfigurationException ex) {
            throw new ParseException("Unable to parse " + xsDate, ex);
        }
    }
@Test
    public void testParseXmlDate() throws ParseException {
        String xsDate = "2019-01-02Z";
        Calendar result = DateUtil.parseXmlDate(xsDate);
        assertEquals(2019, result.get(Calendar.YEAR));
        //month is zero based.
        assertEquals(0, result.get(Calendar.MONTH));
        assertEquals(2, result.get(Calendar.DATE));
    }