Menu

Biweekly.parse drops VTIMEZONE components on the floor

Anonymous
2015-06-05
2015-06-09
  • Anonymous

    Anonymous - 2015-06-05

    I have an iCalendar string with 1 VCALENDAR component that contains 1 VTIMEZONE component. I am attempting to use Biweekly to parse the string and retrieve the TZID from the VTIMEZONE. However, after the string is parsed, in StreamReader.readNext, there is a call to handleTimezones. This call removes all VTIMEZONE components from the ICalendar object. It keeps the information on the reader, however the reader is not accessible through a call to Biweekly.parse. Essentially, I cannot get the timezone component I'm after. Why does Biweekly behave this way? What workarounds are available?

     
  • Michael Angstadt

    Ah, yes. You cannot access the parsed VTIMEZONE components if you are using "Biweekly.parse()". You will need to use the "ICalReader" class instead:

    :::java
    String ical = ...
    try (ICalReader reader = new ICalReader(ical)){
      ICalendar icalendar = reader.readNext();
      TimezoneInfo tzinfo = reader.getTimezoneInfo();
      Collection<VTimezone> vtimezones = tzinfo.getComponents();
    }
    

    In an effort to "purify" the iCalendar data model, biweekly drops the VTIMEZONE components because they are only needed to carry the timezone information for the iCalendar's date/time values. biweekly automatically uses the information in the VTIMEZONE components to properly convert all the date/time values from their respective timezones to UTC (which is how Java's "Date" object stores date/time values).

    But you can still access them if you really need to (as shown above). :)

     
  • Anonymous

    Anonymous - 2015-06-09

    Thank you!

     

Anonymous
Anonymous

Add attachments
Cancel