Page 2 of 6
I have decided to write a calendar applet that, theoretically, could be used in any country that has access to the Internet. Therefore, I need to examine the particular issues surrounding different calendars and holidays across the many countries whose people will be able to access the applet. In some countries, it is customary to start a calendar week on Monday instead of on Sunday. Some countries prefer to represent days on a calendar in a circle, instead of in "our" traditional box. You can see that what seemed like a fairly straightforward task -- that of constructing a calendar applet -- has quickly become a complex task.
Because covering every country, language, custom, and holiday would be prohibitive here, I will try to give you an overview of the coding, algorithms, and techniques required to fully deploy an international calendar, and the facets of Java required to complete our goals. For those of you who wish to explore further some the topics I have mentioned in this article, I recommend "The Calendar FAQ" and Global Interface Design (see the Resources section below).
Java will throw a number of curve balls to those who are not accustomed to its idiosyncrasies. For example, Date.getYear() returns a two-digit year (YYYY - 1900) and months numbered from zero to eleven, while days are numbered one to thirty-one.
I seem to have a memory block with how many days are in each month and continually "shoot myself in the foot" on this one
item. These sorts of "gotchas" can make the fairly straightforward calculation of holidays for the calendar a challenging
proposition.
In the Gregorian calendar, most business holidays are fairly straightforward. They tend to follow one of these rules:
Calculating exactly which Sunday Easter Sunday falls on is difficult compared to the other holidays, because originally it was based on the Hebrew calendar. The Hebrew calendar, along with Mayan and Islamic calendars, are lunar calendars, while the Gregorian calendar we observe is not. A static holiday on a lunar calendar like Easter or Passover requires quite a bit of math to translate it to the Gregorian calendar, this is why Easter and Passover seem to "rove" around the months of March and April of our calendar because they are following the moon and its phases!
Open source projectBy Anonymous on October 31, 2009, 12:24 amhttp://code.google.com/p/jholidays/
Reply | Read entire comment
View all comments