DTSTART=20130926 does not float to system timezone

Help
gjb9876
2013-09-30
2013-10-30
  • gjb9876
    gjb9876
    2013-09-30

    Using ical4j 1.0.5

    I set the following before parsing a new .ics file.

    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true);
    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_UNFOLDING, true);
    System.setProperty("net.fortuna.ical4j.timezone.date.floating", "true");
    CalendarBuilder builder = new CalendarBuilder();

    I have the following in my .ics file:
    BEGIN:VCALENDAR
    VERSION:2.0
    CALSCALE:GREGORIAN

    BEGIN:VEVENT
    DTSTART:20130926
    DTEND:20130927
    DTSTAMP:20130729T234031Z
    UID:allday_startdate_enddate_novalue
    CREATED:20130716T003514Z
    DESCRIPTION:Test 1 2 3
    LAST-MODIFIED:20130716T003857Z
    LOCATION:Los Gatos
    SEQUENCE:0
    STATUS:CONFIRMED
    SUMMARY:Test
    TRANSP:TRANSPARENT
    END:VEVENT

    END:VCALENDAR

    I need to grab the start and end times in UTC millis as follows:
    csid.startTimeMs = vEvent.getStartDate().getDate().getTime();
    csid.endTimeMs = vEvent.getEndDate().getDate().getTime();

    The interesting thing is... (and I suspect a bug in the library, but I'm having trouble digging into the library codebase) When I parse the same .ics file after changing timezones, I get the same UTC time that I got the first time I ran it with the first timezone. Let me clarify :)

    // start in Pacific
    TimeZone.setDefault(TimeZone.getTimeZone("US/Pacific"));
    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true);
    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_UNFOLDING, true);
    System.setProperty("net.fortuna.ical4j.timezone.date.floating", "true");
    CalendarBuilder builder = new CalendarBuilder();
    // blah blah to load and parse the inputstream
    Long pacificMillis = vEvent.getStartDate().getDate().getTime();

    // now change system timezone to Eastern
    TimeZone.setDefault(TimeZone.getTimeZone("US/Eastern"));
    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true);
    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_UNFOLDING, true);
    System.setProperty("net.fortuna.ical4j.timezone.date.floating", "true");
    CalendarBuilder builder = new CalendarBuilder();
    // blah blah to load and parse the inputstream
    Long easternMillis = vEvent.getStartDate().getDate().getTime();

    assertNotEquals(pacificMillis, easternMillis); // expect UTC to be different based on system timezone

    * Everything is fine when the source data is properly containing the "VALUE=DATE" as follows:
    DTSTART;VALUE=DATE:20130926

    I've also tried to force adding the parameter onto the event property, but there is no change in behavior when I do this on the line prior to vEvent.getStartDate();
    vEvent.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE);

    Please help, as I need to be able to support many .ics files from many different sources, each from different timezones, all parsed by a single server.
    Thanks, GJB

     
    • Erich Bremer
      Erich Bremer
      2013-09-30

      Please send all e-mail for me to erich.bremer@stonybrook.edu

       
  • gjb9876
    gjb9876
    2013-10-30

    Does anyone have any information or ideas for me to try?