Converting from LocalDate
to XMLGregorianCalendar
:
LocalDate date = LocalDate.now();
GregorianCalendar gcal = GregorianCalendar.from(date.atStartOfDay(ZoneId.systemDefault()));
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
Converting back is simpler:
xcal.toGregorianCalendar().toZonedDateTime().toLocalDate();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…