Closed nicky-isaacs closed 8 years ago
Nick,
Adding a timezone ID parameter to a property will NOT cause it to be formatted in that timezone. To format a property in a specific timezone, you have to use the writer's TimezoneInfo
object.
ICalendar ical = new ICalendar();
VEvent event = new VEvent();
DateStart dtstart = ...
event.setProperty(dtstart);
DateEnd dtend = ...
event.setProperty(dtend);
ical.addEvent(event);
ICalWriter writer = ...
VTimezone vtimezone = ...
TimeZone timezone = TimeZone.getTimeZone(...);
writer.getTimezoneInfo.assign(vtimezone, timezone);
writer.getTimezoneInfo().setTimeZone(dtstart, timezone);
writer.getTimezoneInfo().setTimeZone(dtend, timezone);
writer.write(ical);
As it stands now, there's no way to assign a timezone to an event as a whole. You have to individually assign each of the event's date/time properties to the timezone. But maybe I will add this feature. Thanks for the idea!
Mike,
Ah! thanks for the info. Will try that. Will look into a PR to support this
Cheers,
Nick
Closing. See https://github.com/mangstadt/biweekly/issues/36
I have multiple
VTIMEZONE
objects specified in my calendar, all of which are being used byVEVENTS
. I do not want to specify a timezone for the calendar as a whole, but rather on individual events.Perhaps I am mistaken, but it seems as though specifying a timezone property on a
VEvent
object should cause it to be serialized without a Zulu time. An example, using Scala but should work same in Java:There is mention in the "Working with Timezones" page about using
icalWriter.getTimezoneInfo().setDefaultTimeZone(tz);
to set timezones for the calendar as a whole. I do not need to specify a global timezone as all events have a timezone specified, however if that is the best solution I could specify a bunk timezone to prevent the Zulu time specification.Hope this makes sense, happy to provide more clarification