O'Reilly logo

Java Cookbook by Ian F. Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Representing Dates in Other Epochs

Problem

You need to deal with dates in a form other than the Gregorian Calendar used in the western world.

Solution

Visit the IBM alphaWorks web site.

Discussion

As of Java 2, the only non-abstract Calendar subclass is the GregorianCalendar, as mentioned previously. However, others do exist. Check out the IBM alphaWorks web site (http://alphaworks.ibm.com), which has a large collection of freely available Java software (mostly without source code, alas). Search for “calendar”, and you’ll find a set of calendars -- Hebrew, Islamic, Buddhist, Japanese, and even an Astronomical Calendar class -- that covers most of the rest of the world.

These work in a similar fashion to the standard GregorianCalendar class, but have constants for month names and other information relevant to each particular calendar.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required