users@jaxb.java.net

Re: dateTime format

From: Greg T Robertson <gregrob_at_us.ibm.com>
Date: Thu, 11 Dec 2003 08:57:51 -0500

I think you may want to take a look at the javaType bindings you can use.
That gives you the ability to specify your own parse and print functions
for any types you choose. More specifically you probably want something
similar to this:

       <jxb:javaType name="java.util.Calendar"
                  xmlType="oa:DateTimeAny"
                  parseMethod="SomeClass.parseCalendar"
                  printMethod="SomeClass.printCalendar" />

this will use the a static method that you provide for parseCalendar and
printCalendar

Regards,

Greg T. Robertson



                                                                                                                                        
                      marcus.walls_at_aspe
                      ctive.com To: users_at_jaxb.dev.java.net
                                               cc:
                      12/11/2003 04:33 Subject: dateTime format
                      AM
                      Please respond to
                      users
                                                                                                                                        




I've recently upgraded one of our systems from the initial RI release to
the 1.0.2 release included in JWSDP1.3.
I had to make a couple of adjustments to the generated runtime to allow
running under 1.2.2 but other than that everything went smoothly.

However, when we hooked our system up to the customer system (our systems
exchange XML messages) the customer system rejected a fair proportion of
our XML - it claimed the timestamps were invalid.

The problem is basically that the customer didn't bother to write a proper
dateTime parser and assumed that milliseconds would always be present.
And it would appear that the JAXB 1.0.2 omits the millisecond part of the
timestamp if it is zero whereas 1.0.0 did not.

I have hunted down the piece of code responsible
(com.sun.msv.datatype.xsd.DateTimeBaseType) which thankfully is in the
open-source bit. By way of experiment, I resolved the problem by
dowloading the nightly build of xsdlib.jar and "fixing" the code. This
appears to work fine.

However, I'm curious to know whether or not there was a specific reason for
adding the "drop zero milliseconds" functionality, or whether it was just
tidying up? I'm not asking for it to be changed - it seems perfectly
reasonable to drop the trailing zeroes - I would just like to understand
the rationale behind it.

Is there a better way to fix the problem other than modifying the JAR? I'm
assuming that since xsdlib.jar is open-source I'm legally permitted to
change it, but as this was an emergency I've not had chance to check that
out yet. So if anybody's got an opinion on that, I'd be interested to hear
it.

Marcus



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net