jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xor exor <makka...@gmail.com>
Subject Re: NodeType.setProperty behaviour
Date Thu, 04 Feb 2010 16:01:46 GMT
On Thu, Feb 4, 2010 at 5:29 PM, Alexander Klimetschek <aklimets@day.com>wrote:

> On Thu, Feb 4, 2010 at 14:15, xor exor <makkalot@gmail.com> wrote:
> > On Thu, Feb 4, 2010 at 5:06 PM, Alexander Klimetschek <aklimets@day.com
> >wrote:
> >
> >> On Thu, Feb 4, 2010 at 13:57, xor exor <makkalot@gmail.com> wrote:
> >> > Well for example i'm getting the date as 2010 12 1 17:00 GMT+2 the
> time
> >> that
> >> > i get from
> >> > ISO8601.format is OK i mean it is GMT0 15:00 then i try to save that
> >> value
> >> > to db with setProperty the date value is messed to something like
> GMT+4
> >> > 19:00
> >>
> >> Should be obvious: 15:00 GMT+00:00 == 19:00 GMT+04:00
> >>
> >
> > Of course it is but what i want to do is save time in database as  15:00
> > GMT+00:00 not as
> > 19:00 GMT+04:00 that is what my method is doing (which source is in my
> first
> > post). My method is creating a Calendar with GMT0 as timezone and passing
> it
> > to setProperty method ,but somehow my date is messed and saved
> differently
> > (with different timezone)to database that is the problem. I hope that is
> > clearer.
>
> Look at your Calendar object (ie. log all important fields, including
> the timezone) directly before you hand it over to setProperty(). I
> guess it does not look like you want. The Java date API is not
> necessarily intuitive and has all its quirks. Just replacing the
> timezone with GMT+0 does not necessarily work, in most cases it is
> best to start with a fresh Calendar object in the new timezone and
> pass it the utc millis from the old calendar.
>

Here is my Calendar that is what i got from eclipse debug

java.util.GregorianCalendar[time=1292256000111,
areFieldsSet=true,
areAllFieldsSet=true,
lenient=true,
zone=java.util.SimpleTimeZone[id=UTC,
offset=0,
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=1,
YEAR=2010,
MONTH=11,
WEEK_OF_YEAR=51,
WEEK_OF_MONTH=3,
DAY_OF_MONTH=13,
DAY_OF_YEAR=347,
DAY_OF_WEEK=2,
DAY_OF_WEEK_IN_MONTH=2,
AM_PM=1,
HOUR=4,
HOUR_OF_DAY=16,
MINUTE=0,
SECOND=0,
MILLISECOND=111,
ZONE_OFFSET=0,
DST_OFFSET=0]

Which means 13 December 2010 16:00 GMT:00

What i have saved in my database is :

13 December 2010 18:00 GMT+2



>
> The setProperty(Date) method should never change anything, it
> internally will only serialize the date as a iso8601 string and then
> stores it like a string property internally.
>

I see,but that is what i got,i spent lots of time digging that Calendar
objects,i hope someone can help me .


>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message