TimeZoneRegistry.getTimeZone always returns null
See original GitHub issueWith version 2.1.5
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
TimeZone timezone = registry.getTimeZone("Portugal");
timezone is always null.
After debugging source code, TimeZoneLoader silently fails in method loadVTimeZone, line 99:
final Calendar calendar = builder.build(resource.openStream());
this fails with IOException: Pushback buffer overflow.
Am i missing something? Can you please check this?
Thanks in advance.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Java Agent XPages: iCal4j TimeZoneRegistry.getTimeZone ...
Java Agent XPages: iCal4j TimeZoneRegistry.getTimeZone returns null ... We have just started using iCal4j for generating iCalendar files.
Read more >Developers - TimeZoneRegistry.getTimeZone always returns null -
With version 2.1.5 TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); TimeZone timezone = registry.getTimeZone("Portugal");.
Read more >Timezones - iCal4j
The iCal4j TimeZoneRegistry is a repository for instance of net.fortuna.ical4j.model.TimeZone , which are essentially implementations of java.util.
Read more >net.fortuna.ical4j.model.TimeZoneRegistry#getTimeZone
TimeZoneRegistry #getTimeZone. ... getTimeZone(tzid); if (timeZone == null) { throw new ... getComponents().add(meeting); } return icsCalendar; }. Example 3 ...
Read more >Java Examples for net.fortuna.ical4j.model.property.ExRule
@param calendar * @param interval * @return * @throws CalendarException ... setDate(datetimeEnd); if (strTZEnd != null) timezone = registry.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I ran into the same issue when I configured ical4j to use HCalendarParserFactory, as suggested by the wiki in the Configuration section. This is because the timezone definitions included in the ical4j release (and ical4j-zoneinfo-outlook) are NOT in hCalendar (XHTML) format, and the code uses the same parser factory regardless of whether it’s reading an actual calendar or just the .ics files that define timezones.
(Note it took some work to figure out that this was the case–since the UnfoldingReader throws pushback buffer overflow exceptions when the patterns it’s trying to unfold occur somewhere other than the end of the read buffer…which is what happens when the code expects XHTML but gets ics text. It would have been easier to debug if the pushback buffer was set to something larger than 3.)
To work around this issue, simply set the following property in your ical4j properties file:
net.fortuna.ical4j.parser=net.fortuna.ical4j.data.DefaultCalendarParserFactory
…though realize by doing so you lose the ability to read hCalendar format.
Alternately, you could replace the timezone definitions (bundled in the jarfiles that are in Maven Central, so you’d have to build locally) with hCalendar equivalents.
The true fix for this would be to have separate parser properties for timezones and calendars.
To get a new parser instance you can use CalendarParserFactory directly:
This will return an instance of the configured custom parser (via proerty
net.fortuna.ical4j.parser
), orCalendarParserImpl
by default.