xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Radhakrishnan J <radhakrishna...@tavant.com>
Subject DateTime format question
Date Thu, 29 Jul 2004 13:23:38 GMT

Whats wrong with this code snippet ?
		XmlOptions options = new XmlOptions();
		Collection errors = new ArrayList();
		XmlDateTime dateTime =

This code prints

[error: Date value is malformed: 1979-10-12T10:10:10.10+5:30]

I rigged it up the xml fragment having read the XML Schema -Datatypes
specification. Am I missing something ? Also, I had a problem with the date
formats. One of our schema components is a date-time type definition defined
as follows :

	<xs:simpleType name="Date">
		<xs:restriction base="xs:date">
			<xs:pattern value="\d\d\d\d-\d\d-\d\d"/>
<!-- restrics the year to 4 digit and does not accept time-zone info -->
	<xs:simpleType name="DateTime">
		<xs:restriction base="xs:dateTime">
value="\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(Z|(\+|-)\d\d:\d\d)"/>	<!--
restricts the year to 4 digit and does not accept fractional seconds -->
	<xs:simpleType name="DateTimeAny">
		<xs:union memberTypes="Date DateTime"/>

The XmlBean generated java type for DateTimeAny is 'java.util.Calendar'.
When a 'Calendar.getInstance()' is passed as an argument to the setter, it
triggers the followoing validation error :

[error: Union '2004-07-29+05:30' does not match any members of DateTimeAny
in namespace http://www.openapplications.org/oagis]

Following one of the earlier mail threads on this topic, I resorted to the
'Calendar.clear(Calendar.ZONE_OFFSET)' before passing the calendar to the
setter. This makes things work fine. However, I would like to retain the
time zone information. Got some questions :

(a) How is the string '2004-07-29+05:30' arrived at ? At the outset seems
like a 'xs:date' type although the calendar instance has all information to
construct a 'xs:dateTime' as well.
(b) Are the above extensions OK ? These schemas have been defined by another
workgroup. Based on the feedback to this question, I might negotiate to
remove the restrictions ( I still don't know why they are there in the first
place ).
(c) If not, How can I get rid of the validation error ?

Extn  367


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

View raw message