users@jaxb.java.net

RE: JAXB and calendar datas

From: <marcus.walls_at_aspective.com>
Date: Wed, 3 Mar 2004 17:27:42 -0000

Apologies if I'm way off on this, as I've not had chance to read the full
history of this thread. However, I have encountered this problem before as
the behaviour changed somewhere between release 1.0 and the current release
I was minded to go and find out where.

This took me to the source code for MSV, and I believe that the code in
question is the class com.sun.msv.datatype.xsd.datetime.CalendarFormatter
and the function is as follows:

    protected void formatSeconds(Object _cal, StringBuffer buf) {
        Calendar cal = (Calendar)_cal;
        formatTwoDigits(cal.get(Calendar.SECOND),buf);
        if (cal.isSet(Calendar.MILLISECOND)) { // milliseconds
            int n = cal.get(Calendar.MILLISECOND);
            if(n!=0) {
                String ms = Integer.toString(n);
                while (ms.length() < 3)
                    ms = "0" + ms; // left 0 paddings.

                buf.append('.');
                buf.append(ms);
            }
        }
    }


Thus as you can see it doesn't print the 000 when the milliseconds are not
set but it also doesn't print milliseconds when they are 0.

Hope that helps.

Marcus


-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Wednesday, March 03, 2004 4:48 PM
To: users_at_jaxb.dev.java.net
Subject: Re: JAXB and calendar datas


> I have recently made some more tests.
>
> The problems rises only for dates with null milli-seconds; that is to say
> dates ending by .000.

To me, a date with no milli-second (presumably that's what you mean by
"null milli-second") and a date with milli-second whose value is .000
are two different things.

The former should be printed without ".000" and the latter should be
printed with ".000". If you find a case that doesn't work like this,
please let us know.

>
> When writing milli-seconds disappeared. The problem is that for the
calendar
> format, dates with and without .000 milliseconds are different....
>
> Sincerely.

regards,
--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net