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.
Get Java Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.