You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Dennis Sosnoski <dm...@sosnoski.com> on 2003/06/03 00:17:47 UTC

Re: sample code: using java.util.Date instead of java.util.Calendar

 From the Schema specification, "dateTime represents a specific instant 
of time". Although a timezone-like offset from UTC is allowed in the 
representation of a dataTime value, as I understand it this is not part 
of the dateTime *value* - in other words, it's just a convenience that 
is meant to be stripped away during parsing of the value, just like 
leading zeroes on a number. This is implied by both the definition of 
dateTime and by the canonical representation, which does not allow an 
offset.

That makes the (non-deprecated) java.util.Date the closest match to a 
dateTime. The problem is that people keep trying to add timezone 
information (even though it's not supported by Schema), which is 
apparently why the JAX-RPC spec requires using Calendar instead. 
Calendar is specifically "for converting between a Date object and a set 
of integer fields such as YEAR, MONTH, DAY, HOUR, and so on", and 
requires a specific time zone and associated set of conversion rules in 
order to be meaningful. Trying to match up a Schema dateTime with a 
Calendar is ambiguous at best - for instance, what timezone do you 
attach to 2003-10-26T01:15:00-05:00 (which can be either 1:15 am CDT or 
1:15 am EST, if I got my math right).

I think this really is an error in the JAX-RPC spec, though I doubt 
they'll be willing to make a change. You know Schema better than I do, 
Stu - what do you think?

  - Dennis

Dennis M. Sosnoski
Enterprise Java, XML, and Web Services Support
http://www.sosnoski.com
Redmond, WA  425.885.7197


Stu Halloway (DevelopMentor) wrote:

>Hi,
>
>In response to "ow"s request for java.util.Date <-> xsd:dateTime
>conversion, I have written an Axis sample that uses a custom generator
>in WSDL2Java to bind dateTime to java.util.Date instead of
>java.util.Calendar. You can download the sample set at [1], the sample
>is called StaffLocator.
>
>Note: I am not endorsing (or condemning) this approach and I understand
>that this mapping is contra the JAX-RPC spec. It's just a sample. :-)
>
>Please let me know if there are better approaches or if there are other
>samples you would like to see.
>
>Stu
>
>[1] http://staff.develop.com/halloway/wsdlAndAxis/axisSamples.zip
>
>Stuart Halloway
>DevelopMentor
>Guerrilla Java Web Services June 16! 
>http://www.develop.com/courses/gjws 
>
>
>  
>