jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xor exor <makka...@gmail.com>
Subject NodeType.setProperty behaviour
Date Thu, 04 Feb 2010 14:28:13 GMT
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
btw the value that comes from : ISO8601.format is OK ,but setProperty is
doing something nasty ? Any suggestions how to solve problem ? Is it a bug
or feature ?

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