question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TimeZoneRegistry.getTimeZone always returns null

See original GitHub issue

With 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:open
  • Created 6 years ago
  • Reactions:2
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
dbularzikcommented, Mar 1, 2018

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.

1reaction
benfortunacommented, Feb 28, 2022

To get a new parser instance you can use CalendarParserFactory directly:

CalendarParser parser = CalendarParserFactory.getInstance();

This will return an instance of the configured custom parser (via proerty net.fortuna.ical4j.parser), or CalendarParserImpl by default.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found