How do i compare 2 instances of XMLGregorianCalendar to find which one is greater? One of the date variables have a value
date1 = 2009-02-23T05:54:17+05:30
and the other,
date2 = 2009-02-23T05:54:17.000
How do i compare 2 instances of XMLGregorianCalendar to find which one is greater? One of the date variables have a value
date1 = 2009-02-23T05:54:17+05:30
and the other,
date2 = 2009-02-23T05:54:17.000
You could convert them both to GregorianCalendar and compare those (Calendar is Comparable). The semantics compareTo() method of Calendar is explicitly defined, and should work independent of the timezone:
Compares the time values (millisecond offsets from the Epoch) represented by two Calendar objects.
So try this:
XMLGregorianCalendar date1 = ...
XMLGregorianCalendar date2 = ...
int result = date1.toGregorianCalendar().compareTo(date2.toGregorianCalendar());
If result is positive, then date1 is "later" than date2
The compare() method on XMLGregorianCalendar itself does something rather peculiar, and doesn't look very useful to me.