The DateTimeZoneBuilder class is what you need for this task. The builder is focussed around being easy to use from the tz database format, but the iCal data is similar.
Here is the example: * DateTimeZone America_Los_Angeles = new DateTimeZoneBuilder() Initial setup * .addCutover(-2147483648, 'w', 1, 1, 0, false, 0) * .setStandardOffset(-28378000) * .setFixedSavings("LMT", 0) These three lines are a one-time cutover * .addCutover(1883, 'w', 11, 18, 0, false, 43200000) * .setStandardOffset(-28800000) These two lines are also a one time cutover * .addRecurringSavings("PDT", 3600000, 1918, 1919, 'w', 3, -1, 7, false, 7200000) * .addRecurringSavings("PST", 0, 1918, 1919, 'w', 10, -1, 7, false, 7200000) These two lines are the transition into and out of DST. * .toDateTimeZone("America/Los_Angeles", true); Setup the final object. Hope that helps Stephen On 15 February 2010 20:54, itin...@gmx.com <itin...@gmx.com> wrote: > Can someone explain how to create a DateTimeZone using > DateTimeZoneBuilder instead one of the prebuilt zones? > > I need to convert from local date/times with time zone information into > UTC and back again. This is so I can process ics (iCal) entries where > date/times are expressed like: > > DTSTART;TZID="(GMT) Greenwich Mean Time - Dublin / Edinburgh / Lisbon / > London":20100117T130000 > > I can see that DateTimeZone supports conversion methods to and from UTC, > however I don't understand how to create the DateTimeZone object which > is also defined in the same ics file as follows: > > BEGIN:VTIMEZONE > TZID:(GMT) Greenwich Mean Time - Dublin / Edinburgh / Lisbon / London > BEGIN:STANDARD > DTSTART:16010101T020000 > TZOFFSETTO:-0000 > TZOFFSETFROM:+0100 > RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU > END:STANDARD > BEGIN:DAYLIGHT > DTSTART:16010101T010000 > TZOFFSETTO:+0100 > TZOFFSETFROM:-0000 > RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU > END:DAYLIGHT > END:VTIMEZONE > > I looked at the example given in the DateTimeZoneBuilder javadoc but > couldn't understand how to create a DateTimeZone with the above > VTIMEZONE information. > > I can see that the tzdata2010b TZ database looks similar to the RRULE > above, so I'm hoping this isn't going to be too hard. > > Can someone help explain how to use the DateTimeZoneBuilder class to > process the timezone rules above to build a custom DateTimeZone object? > > Thanks > > John > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Joda-interest mailing list > Joda-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/joda-interest > ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest