Class PersianCalendar

All Implemented Interfaces:
Serializable

public class PersianCalendar extends MonthDayYear
Implementation of the Persian (Solar Hijri) calendar. The Persian calendar is a solar calendar used officially in Iran and Afghanistan. It is one of the most accurate calendars in use.

Key features:

  • Epoch: March 19, 622 CE (Julian) - the Hijra
  • Uses a 2820-year grand cycle for leap year calculation
  • First 6 months have 31 days, next 5 have 30, last has 29 (30 in leap years)
  • Years are marked with "A.P." (Anno Persico)
* @version 2.0
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
See Also:
  • Field Details

    • EPOCH

      public static long EPOCH
      The RD (Rata Die) number for the Persian calendar epoch.
  • Constructor Details

    • PersianCalendar

      public PersianCalendar()
      Creates a new PersianCalendar object.
    • PersianCalendar

      public PersianCalendar(long l)
      Creates a new PersianCalendar object.
      Parameters:
      l - the Rata Die number to set.
    • PersianCalendar

      public PersianCalendar(int i, int j, int k)
      Creates a new PersianCalendar object.
      Parameters:
      i - the month (1-12).
      j - the day (1-31).
      k - the year.
    • PersianCalendar

      public PersianCalendar(AlternateCalendar altcalendar)
      Creates a new PersianCalendar object.
      Parameters:
      altcalendar - another calendar to initialize from.
  • Method Details

    • fixedFromPersian

      public static long fixedFromPersian(long year, int month, int day)
      Computes the Rata Die number from the given Persian date.
      Parameters:
      year - the year.
      month - the month.
      day - the day.
      Returns:
      the Rata Die number.
    • recomputeRD

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

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

      public void set(long l)
      Sets the Rata Die number and recomputes the date.
      Specified by:
      set in class AlternateCalendar
      Parameters:
      l - the Rata Die number.
    • isLeapYear

      public static boolean isLeapYear(int i)
      Checks if the given year is a leap year in the Persian calendar.
      Parameters:
      i - the year to check.
      Returns:
      true if it is a leap year, false otherwise.
    • monthName

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

      protected String getSuffix()
      Returns the suffix for Persian years ("A.P.").
      Specified by:
      getSuffix in class MonthDayYear
      Returns:
      the year suffix.
    • getMonths

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

      public static void main(String[] args)
      Main method for testing the Persian calendar implementation.
      Parameters:
      args - command line arguments (year, month, day).