How to subtract one day in XMLGregorianCalendar? Also while subtracting how to cope up with following problems :
and other similar stuffs.
Please do not suggest to use any other library like Joda-Time. I know they are great, but I need to get this done using XMLGregorianCalendar only.
Thanks
Just convert to a normal GregorianCalendar
, do the arithmetic there, then convert back:
GregorianCalendar calendar = xmlCalendar.toGregorianCalendar();
calendar.add(Calendar.DAY_OF_MONTH, -1);
xmlCalendar = datatypeFactory.newXMLGregorianCalendar(calendar);
(This assumes you already have a DatatypeFactory
of course. You can always call DatatypeFactory.newInstance()
if necessary.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With