Class IslamicCalendar

All Implemented Interfaces:
Serializable

public class IslamicCalendar extends MonthDayYear
Implementation of the Islamic (Hijri) calendar using the tabular arithmetic method. The Islamic calendar is a purely lunar calendar with 12 months alternating between 29 and 30 days, resulting in either 354 or 355 days per year.

Key features:

  • Epoch: July 16, 622 CE (Julian) - the Hijra of Prophet Muhammad
  • Uses a 30-year cycle with 11 leap years (years 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, 29)
  • Months alternate between 29 and 30 days
  • Years are marked with "A.H." (Anno Hegirae)

Note: This is the tabular/arithmetic Islamic calendar. The actual religious calendar may differ as it is based on lunar observation.

* @version 2.0
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
See Also:
  • Field Details

    • EPOCH

      public static long EPOCH
      The Islamic epoch: July 16, 622 CE (Julian calendar).
  • Constructor Details

    • IslamicCalendar

      public IslamicCalendar()
      Creates an Islamic calendar set to the epoch (1 Muharram, 1 AH).
    • IslamicCalendar

      public IslamicCalendar(long rataDie)
      Creates an Islamic calendar set to the specified Rata Die.
      Parameters:
      rataDie - the day number
    • IslamicCalendar

      public IslamicCalendar(int year, int month, int day)
      Creates an Islamic calendar set to the specified date.
      Parameters:
      year - the Hijri year
      month - the month (1-12)
      day - the day of month (1-30)
    • IslamicCalendar

      public IslamicCalendar(AlternateCalendar calendar)
      Creates an Islamic calendar from another calendar's date.
      Parameters:
      calendar - the source calendar
  • Method Details

    • recomputeRD

      protected void recomputeRD()
      Recomputes the Rata Die from the current year, month, and day fields.
      Specified by:
      recomputeRD in class AlternateCalendar
    • recomputeFromRD

      protected void recomputeFromRD()
      Recomputes the year, month, and day fields from the current Rata Die.
      Specified by:
      recomputeFromRD in class AlternateCalendar
    • set

      public void set(long rataDie)
      Sets this calendar to the specified Rata Die and recomputes the date fields.
      Specified by:
      set in class AlternateCalendar
      Parameters:
      rataDie - the new Rata Die value
    • isLeapYear

      public static boolean isLeapYear(int year)
      Determines if the specified year is a leap year in the Islamic calendar. Leap years in the 30-year cycle are: 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, 29.
      Parameters:
      year - the Hijri year
      Returns:
      true if it's a leap year
    • monthName

      protected String monthName()
      Returns the name of the current month.
      Specified by:
      monthName in class MonthDayYear
      Returns:
      the month name
    • getSuffix

      protected String getSuffix()
      Returns the era suffix for display.
      Specified by:
      getSuffix in class MonthDayYear
      Returns:
      " A.H." (Anno Hegirae)
    • getMonths

      public Enumeration<String> getMonths()
      Returns an enumeration of month names.
      Specified by:
      getMonths in class MonthDayYear
      Returns:
      month names enumeration