On 23/09/2011 14:03, Christophe Marchand wrote:
I have a strange behavior with JAXP date comparisons :
Here is a sample code :
DatatypeFactory df =
XMLGregorianCalendar d1 =
XMLGregorianCalendar d2 =
ret = (d1.compare(d2) <=
Comparing 2011-09-23T11:17:21.815+02:00 to 2011-09-24 responds
that first date is not before second date.
Comparing 2011-09-23T11:17:21.815+02:00 to 2011-09-25 responds
that first date is before second date.
I think there is a bug here ; timezone is not so different that
difference is more than 12 hours.
I suspect that this is following the XSD semantics for date/time
comparison, rather than the XPath semantics, which are different.
the XSD rules give a result of "interdeterminate ordering" if the
range of possible dateTime values for 2011-09-24 overlaps the
specific dateTime given.
Implementation I have is
I would be inclined to use Saxon's net.sf.saxon.value.DateTimeValue
class, which implements both the XPath and XSD semantics, depending
whether you call getXPathComparable() or getSchemaComparable() to
get the object that you use for comparison.
Is there a Saxon replacement for this, and how could I use it ?