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 14:57:01 GMT
On Thu, Feb 4, 2010 at 4:43 PM, Stefan Guggisberg <
stefan.guggisberg@gmail.com> wrote:

> On Thu, Feb 4, 2010 at 3:28 PM, xor exor <makkalot@gmail.com> wrote:
> > Hi,
> >
> > In my application i'm trying to save my models' date fields as Gmt0 to my
> > database (my server is gmt+8)
> > so here is how i'm doing it :
> >
> > Using jackrabbit 1.54
> >
> > Node storyNode = newsNode.addNode(storyNodeName_,
> > ContentConstants.NODE_TYPE_STORY);
> > storyNode.setProperty("startDate",
> > ISO8601.format(ContentDateUtil.getCalToGMT0(story.getStartDate(),
> > ContentDateUtil.getUserTimeZoneOffset())),PropertyType.DATE);
> >
> >
> > and here is the  getCalToGMT0 :
> >
> > public static GregorianCalendar getCalToGMT0(Date userDate,int
> > userTimeZoneOffset){
> >        //create a dummy calendar only for getting datefields
> >        Calendar tmpCal = Calendar.getInstance();
> >        tmpCal.setTime(userDate);
> >
> >        //create a joda datimezone with customtimezoneoffset
> >        DateTimeZone jodaCustomTimeZone =
> > DateTimeZone.forOffsetHours(userTimeZoneOffset);
> >        //create a joda datetime with current userdate and
> > userTimeZoneOffset
> >        DateTime jodaCustomDateTime = new
> > DateTime(tmpCal.get(Calendar.YEAR),
> >                tmpCal.get(Calendar.MONTH)+1,
> >                tmpCal.get(Calendar.DAY_OF_MONTH),
> >                tmpCal.get(Calendar.HOUR_OF_DAY) ,
> >                tmpCal.get(Calendar.MINUTE),
> >                tmpCal.get(Calendar.SECOND),
> >                tmpCal.get(Calendar.MILLISECOND),
> >                jodaCustomTimeZone);
> >
> >        //create a joda gmt time zone
> >        DateTimeZone gmtTimeZone = DateTimeZone.forOffsetHours(0);
> >
> >        //convert custom timezone to gmt0
> >        DateTime dtGMT = jodaCustomDateTime.withZone(gmtTimeZone);
> >        GregorianCalendar gmtGreg = dtGMT.toGregorianCalendar();
> >
> >        return gmtGreg;
> >    }
> >
> >
> > Here is the summary of my code
> >
> > i create a Node then put a calendar which is set to GMT0,but somehow the
> > setNodeProperty is messing with date and saving it as wrong value to the
> > database
>
> setNodeProperty? what are you refering to? there's no such method in
> the JCR api.
>

Yes sorry it is org.apache.jackrabbit.core.NodeImpl.setProperty


>
> what wrong value? what database?
>

Well what i'm doing is getting user (in user's timezone) date convert it to
GMT0 and saving to repository.Which obviosly uses jcr,
btw the db is mysql

>
> > btw the value that comes from : ISO8601.format is OK ,but setProperty is
> > doing something nasty ?
>
> what is wrong?
>

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


>
> > Any suggestions how to solve problem ?
>
> what problem?
>

?


>
> cheers
> stefan
>
> > Is it a bug
> > or feature ?
> >
>

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