Hi K,
Well, I /was/ planning on using an xs:duration attribute to specific a time
out for one of our long lived component, where seconds is just fine as the
level of granularity and quite easier to read than a milliseconds number.
Typically, the attribute value would be a couple minutes at most. So if the
attribute read "PT0H1M", that means one minute = 60000 milliseconds. Getting
a long for seconds or milliseconds or some kind of number is nice since you
can then work with it and compare to System.currentTimeMillis().
Using xs:duration for this also lets me use a nicer name for the attribute
like "clientSessionTimeOut" instead of "clientSessionTimeOutMillis". Having
the scale of the number in the name is just asking for trouble IMHO. I also
do not want to invent <clientSessionTimeOut
scale="seconds">1<\clientSessionTimeOut>
Getting "PT0H1M" is not nice since I cannot get a number for it out of the
box. So my options are:
(1) Find some library out there that does xs:duration ISO format <-> long
conversion.
(2) Use a xs:positiveInteger instead.
Thanks,
Gary
-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Tuesday, July 15, 2003 17:23
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Better xs:duration support?
Gary Gregory <ggregory_at_seagullsw.com> wrote:
> Hello,
>
> Are there any plans to support unmarshalling of xs:duration to something
> more interesting that a String? To a long representing seconds for
example,
> since seconds seems to be the smallest level of granularity for that type
> ("PT0H0M1S" = 1 second)?
>
> Is there a doo-dad in JAXB buried somewhere that does this?
There's a plan. But there's nothing in the current release. Any
contribution of the conversion code is welcome, though.
If you have any requirements on the duration support (e.g., how does
your program manipulate durations?), please let us know.
regards,
--
Kohsuke Kawaguchi 408-276-7063 (x17063)
Sun Microsystems kohsuke.kawaguchi_at_sun.com