0

We have a system written in java which sends iCal events to clients.

One customer has a problem that all events sent from our system are represented in their outlooks 2 hours late as it is specified in the iCal(VCALENDAR) content.

The customer assures they have the timzone set correctly on their computers, so to Central European time. We have tested the same event on our email clients internal and in our clients (mainly Outlook) the events are correctly displayed.

We use iCal4J to construct the mime message. Is there any parameter that should I set additional to enhance the time accuracy of the event on different clients?

For example the following event was set for 10:00 till 12:00 but our customer has it represented in their outlook as 12:00 till 14:00, in our outlook the same event is shown correctly.

Here is an example of our event body:

From: =?UTF-8?Q?Tanja_Bla=C5=BEi=C4=8D?= <******@****.***>
To: Petra Lunder <******.******@******.***>
Message-ID: <15605406.0.1409569454863.JavaMail."****.*****"@*******>
Subject: test sestankov - testni sestanek 1
MIME-Version: 1.0
Content-Type: text/calendar; method=REQUEST; charset="utf-8"
Content-Transfer-Encoding: 8bit

BEGIN:VCALENDAR
PRODID:-//4pm - Arctur d.o.o.//iCal4j 1.0//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTAMP:20140901T110414Z
DTSTART:20140912T100000
DTEND:20140912T120000
SUMMARY:test sestankov - testni sestanek 1
TZID:Europe/Prague
ORGANIZER;CN=Tanja Blažič:mailto:********@***********
LOCATION:
DESCRIPTION:testni sestanek\n---------------------------------------\nsta
 tus dogodka: potrjen\n---------------------------------------\ntrenutno 
 stanje udeležbe na dogodku\n-------------------------------------\nPetra
  Lunder - nedoločeno\nSimon Cigoj - nedoločeno\nVesna Kobal - nedoločeno
\n
SEQUENCE:0
UID:2010250@em_4pm_a
STATUS:CONFIRMED
ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE;CN=Petra Lunder;PARTSTAT=NEEDS-AC
 TION:mailto:******.******@*****.**
 ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE;CN=Simon Cigoj;PARTSTAT=NEEDS-ACT
ION:mailto:******.******@*****.**
 ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE;CN=Vesna Kobal;PARTSTAT=NEEDS-ACT
 ION:mailto:******.******@*****.**
END:VEVENT
END:VCALENDAR

My java ical4j code :

    DateTime start = new DateTime(_startDate);
    DateTime end = new DateTime(_endDate);

    //meeting = new VEvent(start, end, StringUtilities.clearLatinLetters(_sumamry));
    meeting = new VEvent(start, end, _sumamry);

    TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
    VTimeZone tz = registry.getTimeZone(LocaleUtil.getTimeZoneID()).getVTimeZone();

    Organizer $organizer = new Organizer(URI.create("mailto:" + _organizerEmail));
    $organizer.getParameters().add(new Cn(_organizerName));
    meeting.getProperties().add($organizer);

    Location $location = new Location(_location);
    meeting.getProperties().add($location);

    Description $description = new Description(_description);
    meeting.getProperties().add($description);

    meeting.getProperties().add(new Sequence(Integer.parseInt(_sequence + "")));

    meeting.getProperties().add(new Uid(_customerEventId));


    calendar = new Calendar();
    // $calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
    calendar.getProperties().add(new ProdId("-//4pm - Arctur d.o.o.//iCal4j 1.0//EN"));
    calendar.getProperties().add(Version.VERSION_2_0);
    calendar.getProperties().add(CalScale.GREGORIAN);
    calendar.getProperties().add(_method.toIcal4j());
    calendar.getComponents().add(meeting);
    calendar.getComponents().add(tz);
simonC
  • 4,101
  • 10
  • 50
  • 78

2 Answers2

1

Extending Oberron's answer, to put zoned times in Icalendar, you need a top level VTIMEZONE element that defines the timezone and a TZID attribute in the time, eg. DTSTART;TZID=Europe/Prague:20140912T100000. TZID should not be sitting out on it's own, unrelated to a time, to my eyes.

Ical4j should do this for you. See this page. Try loading the timezone registry as shown...

TimeZoneRegistry registry = builder.getRegistry();
bbsimonbb
  • 27,056
  • 15
  • 80
  • 110
  • I have seen the ical4j wiki page and folowed their exampled but the result is the same. I have updated the question also with my java code. If I use the VTimeZone the top level element VTIMEZONE is not created in the message but only the TZID alone is created. – simonC Sep 08 '14 at 11:19
  • In your code, I can't see the magic line "calendar.getComponents().add(tz);" ?? – bbsimonbb Sep 08 '14 at 13:39
  • Ok I've added the timezone to calendar, now outlook says "not supported calendar message" :-) I have used Europe/Prague as tzid, the VTIMEZONE is added as top level element but looks like outlook doesnt likes it. – simonC Sep 08 '14 at 14:04
  • Sounds like you're getting there, but outlook can be ridiculously picky. First try validating your icalendar with the [online validators](http://stackoverflow.com/questions/2643441/icalendar-not-readable-by-google-calendar). Then send yourself an invitation from gmail and compare it to the invitations your app generates. The order of fields is important. Don't hesitate to post your current icalendar. – bbsimonbb Sep 08 '14 at 14:40
0

The most likely reason for this issue is that the property TZID is set to Europe/Prague, but you did include in your calendar a component VTIMEZONE ( see RFC5545 3.6.5), the reason it works on some systems is that Outlook and other have added support for Olson timezone, but this is not stricto sensu part of the RFC standard.

Community
  • 1
  • 1
Auberon Vacher
  • 4,655
  • 1
  • 24
  • 36