Skip to content

How do you get a VTimeZone from DtStart in ical4j 4.x? #752

Answered by benfortuna
mosesn asked this question in Q&A
Discussion options

You must be logged in to vote

To get a VTIMEZONE from a date property with iCal4j 4.x you first need to get the ZoneId and use it to look up the timezone registry.

With iCal4j 3.x this lookup was encapsulated in DtStart#getTimeZone, but has been decoupled to support the new date/time API.

To get the zone id use:

TzId tzid = prop.getRequiredParameter("TZID");
ZoneId zoneid = tzid.toZoneId(); // or;

TimeZoneRegistry tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry(); // use this registry in calendar builder, etc. to register tz definitions from input data
ZoneId zoneid = tzid.toZoneId(tzRegistry);

To get the VTIMEZONE use:

TimeZone tz = tzRegistry.getTimeZone(zoneid.getId());
VTimeZone vtz = tz.getVTim…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mosesn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants