xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Krouse <kkro...@bea.com>
Subject XmlCalendar to java.util.Date with Julian dates
Date Thu, 04 Mar 2004 20:03:41 GMT
I've come across an interesting problem with how xmlbeans handles a
conversion from XmlCalendar to java.util.Date and I'd like to see if
this is by design or not.

In XMLSchema, dates are Gregorian only -- there is no Julian date as far
as I can tell.  Please correct me if I'm wrong on that point.  Given a
XmlCalendar representation of a date which is before the 1584 Julian to
Gregorian cutoff (say, "1550-01-02T00:00:00Z"), when we convert to a
java.util.Date using .getTime() we let the java.util.GregorianCalendar
base class create the Date.  The Date now represents "1550-01-02" in
*Gregorian* time.  This is all fine and good.

Now, calling getters or .toString() on the Date in hand, the Date
implementation uses a java.util.GregorianCalendar under the hood and so
interprets the Date as a *Julian* date since it is before 1584.  The
result is it looks like that Date is "Sun Dec 22 16:00:00 PST 1549". 
Note that both the date is "wrong" and a timezone is added. sigh.

So a few questions:

1) Is this a real problem and do we care?  Date isn't that useful
especially since we already have a XmlCalendar which extends Calendar.

2) Should we take into account this Julian/Gregorian discrepancy when
creating Date from XmlCalendar and vice-versa?

3) Should we sub-class java.util.Date in xmlbeans and just return that
class which would be Gregorian only?

to me, this feels by design and more or less a problem with the JDK.


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/

View raw message