Apr 16th, 2008, 07:17 AM
XMLGregorianCalendar versus java.util.Date
I was ignorant of the XMLGregorianCalendar type until I saw it in the Spring WS Axis client for the airline sample. I was surprised to see this touted as a "standard".
How can it be that when there are several calendars in use around the world that XML can standardize on Gregorian in this way? They've gone to great pains to make XML support Unicode. Why just one calendar and one standard date format?
I'm working on apps for international offices these days, so I've become more aware of I18N than I would have thought possible. Still lots to learn, though.
Apr 16th, 2008, 10:32 PM
XMLGregorianCalendar is based on representing time as specified in ISO8601. They had to pick one representation of dates and times in XML and that was the one they chose. Localisation issues (such as converting from ISO8601 to local calendar) should be handled by the application not the data interchange format.
Apr 18th, 2008, 05:40 AM
Dates and calendars are a pain in Java. So until we get JSR 310, I would suggest using the excellent Joda Time for all your date & time handling.
The only reason I don't use it by default in Spring-WS is that it's an extra dependency, and I don't want to require it.
Apr 18th, 2008, 08:34 AM
Thank you, Arjen. Your advice and the web services module are both most welcome.