JFXtras / jfxtras

A supporting library for JavaFX, containing helper classes, extended layouts, controls and other interesting widgets.
http://jfxtras.org
Other
599 stars 123 forks source link

Microsoft Outlook use different time zone id's #118

Open Olafxso opened 4 years ago

Olafxso commented 4 years ago

Hi,

I want to import an .ics calendar from Microsoft Outlook

BEGIN:VCALENDAR
METHOD:PUBLISH
PRODID:Microsoft Exchange Server 2010
VERSION:2.0
X-WR-CALNAME:Agenda
BEGIN:VTIMEZONE
TZID:W. Europe Standard Time
BEGIN:STANDARD
DTSTART:16010101T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:040000008200E00074C5B7101A82E008000000006686FB75C993D501000000000000000
 01000000007C1F67A981E724D83DDDD3B1FB05AA1
SUMMARY:fsdfs
DTSTART;TZID=W. Europe Standard Time:20191105T130000
DTEND;TZID=W. Europe Standard Time:20191105T180000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20191107T121453Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION:
X-MICROSOFT-CDO-APPT-SEQUENCE:0
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
END:VEVENT
BEGIN:VEVENT
UID:040000008200E00074C5B7101A82E0080000000048937278C993D501000000000000000
 0100000008542DE7D4319974697ADEAA9840EA5D3
SUMMARY:dfsdfsfs
DTSTART;TZID=W. Europe Standard Time:20191105T183000
DTEND;TZID=W. Europe Standard Time:20191105T220000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20191107T121453Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION:
X-MICROSOFT-CDO-APPT-SEQUENCE:0
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
END:VEVENT
END:VCALENDAR

An error occurs while parsing this file :

java.time.DateTimeException: Invalid ID for region-based ZoneId, invalid format: W. Europe Standard Time
    at java.time.ZoneRegion.checkName(ZoneRegion.java:151) ~[?:1.8.0_181]
    at java.time.ZoneRegion.ofId(ZoneRegion.java:116) ~[?:1.8.0_181]
    at java.time.ZoneId.of(ZoneId.java:411) ~[?:1.8.0_181]
    at java.time.ZoneId.of(ZoneId.java:359) ~[?:1.8.0_181]
    at jfxtras.icalendarfx.parameters.VParameterElement$20$1.fromString(VParameterElement.java:322) ~[jfxtras-icalendarfx.jar:?]
    at jfxtras.icalendarfx.parameters.VParameterBase.parseContent(VParameterBase.java:71) ~[jfxtras-icalendarfx.jar:?]
    at jfxtras.icalendarfx.VParentBase.processInLineChild(VParentBase.java:333) ~[jfxtras-icalendarfx.jar:?]
    at jfxtras.icalendarfx.properties.VPropertyBase.processInLineChild(VPropertyBase.java:474) ~[jfxtras-icalendarfx.jar:?]
    at jfxtras.icalendarfx.properties.VPropertyBase.lambda$6(VPropertyBase.java:434) ~[jfxtras-icalendarfx.jar:?]
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_181]
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[?:1.8.0_181]
    at jfxtras.icalendarfx.properties.VPropertyBase.parseContent(VPropertyBase.java:434) ~[jfxtras-icalendarfx.jar:?]
    at jfxtras.icalendarfx.VParentBase.parseContent(VParentBase.java:301) ~[jfxtras-icalendarfx.jar:?]
    at jfxtras.icalendarfx.VParentBase.parseContent(VParentBase.java:283) ~[jfxtras-icalendarfx.jar:?]

The RFC-5545 describes the syntax TZID is invalid also. So I don't think you code is wrong, but do you know about this? Do you know a workaround?

Thanks

daviddbal commented 4 years ago

This problem is a result of the Java time library not identifying the time zone provided by Outlook - it's a non-standard time zone. Can you configure Outlook to provide a standard time zone?

Olafxso commented 4 years ago

There are no settings for generating the .ics file.

daviddbal commented 4 years ago

How is the time zone set on the computer? Can the selection be made there?

Olafxso commented 4 years ago

No, It comes from the online version of outlook. So I don't think computer time zone settings will have effect. It looks like windows uses a different TimeZone ID format. I found some mappings like here: https://unicode.org/cldr/charts/latest/supplemental/zone_tzid.html Also newer Java version (I use java 8) are known about this format and have got a mapping file in 'jre\lib\tzmapping'

daviddbal commented 4 years ago

Can you upgrade your Java version? If not, you can write a preprocessor that does a simple string substitution to replace the W. Europe Standard Time for a time zone that fits and Java 8 understands (e.g.TZID:Europe/London)

Olafxso commented 4 years ago

I cannot upgrade Java yet. Is there a way to 'override' the TIME_ZONE_IDENTIFIER in jfxtras.icalendarfx.parameters.VParameterElement? Or add a custom property reader or something?

Or should I create a method which read the ics file to a string and replace all the possible strings. There could by more than 100 possible zone ids. This will take some time I think.