users@jaxb.java.net

Re: Daylight Savings Time problem and JAXB: HELP!

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 23 Apr 2003 11:27:53 -0700

I tried the following schema:

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="foo" type="xs:dateTime" />
    </xs:schema>

... with the following document:

    <foo>2003-04-23T09:47:23.211-08:00</foo>

and unmarshalled a document, then marshalled it back to XML, and I got:

    <foo>2003-04-23T09:47:23.211-08:00</foo>

I also printed out the Calendar object in the content tree, and I got:

    java.util.GregorianCalendar[time=?,areFieldsSet=false,
    areAllFieldsSet=false,lenient=true,zone=java.util.SimpleTimeZone[i
    d=custom,offset=-28800000,dstSavings=3600000,useDaylight=false,
    startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,
    startTime=0,startTimeMode=0,endMode=0,endMonth=0,endDay=0,
    endDayOfWeek=0,endTime=0,endTimeMode=0],firstDayOfWeek=1,
    minimalDaysInFirstWeek=1,ERA=?,YEAR=2003,MONTH=3,WEEK_OF_YEAR=?,
    WEEK_OF_MONTH=?,DAY_OF_MONTH=23,DAY_OF_YEAR=?,DAY_OF_WEEK=?,
    DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=9,MINUTE=47,
    SECOND=23,MILLISECOND=211,ZONE_OFFSET=?,DST_OFFSET=?]

If you look at it, it shows it's not seting the daylight saving time
with the time zone, which is correct. (Since you can't tell if you
should apply time zone just from "-08:00")

Now, if I call the Calendar.getTime() method, it will turn it into a
Date object, but the Date object don't keep the time zone in it. So it
just uses the default system time zone, which is why you see PDT.

I don't fully understand the problem you described, but hopefully this
will give you enough clue to get things right.


regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com