Quick Introduction:
For those who don't know; Jollyday is an API to help you handle holiday-aware code. It allows you to retrieve public holidays from pre-built configurations. You can even create your own Holiday Configuration in an XML file and load it into the API, which is exactly what I'm trying to do.
I have created my own holiday configuration in an XML file and I want to load it into Jollyday.
The Official Jollyday Documentation (for version 0.5.1) shows an example of this being done with the following code...
URL url = new URL("file:some/path/MyHolidays.xml");
HolidayManager m = HolidayManager.getInstance(url);
When I try to use this code, it will not compile because the HolidayManager
class does not have a getInstance(URL)
method.
Here is a screenshot of all the overloaded variations of HolidayManager.getInstance()
(as seen from IntelliJ IDEA).
The documentation appears to be incorrect.
"Are you using the correct version of the API?"
Yes, I am using version 0.5.1 which I downloaded with gradle. This is the same version as was used in the documentation.
Is it possible to create a HolidayManager instance using a URL?
If so, how is it done?
Is it possible to create a HolidayManager instance using a URL?
The documentation appears to be incorrect.
The documentation became slightly outdated when the code migrated from SourceForge to GitHub in late 2011.
If you look at the GitHub Commit History of HolidayManager
, you can see that the HolidayManager.getInstance(URL)
method was removed in this commit.
URL url = new URL("file:some/path/MyHolidays.xml");
UrlManagerParameter urlManParam = new UrlManagerParameter(url, new Properties());
HolidayManager holidayManager = HolidayManager.getInstance(urlManParam);
This will work exactly as you expected, it just takes a few extra lines. You should use nicer variable names too, I just wanted to keep it short.
Don't forget to import the following classes:
import de.jollyday.HolidayManager;
import de.jollyday.parameter.UrlManagerParameter;
import java.net.URL;
import java.util.Properties;
You can now load Custom Holiday Configurations into Jollyday. Enjoy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With