Class PersianCalendar
java.lang.Object
org.episteme.social.history.calendars.AlternateCalendar
org.episteme.social.history.calendars.SevenDaysWeek
org.episteme.social.history.calendars.MonthDayYear
org.episteme.social.history.calendars.PersianCalendar
- All Implemented Interfaces:
Serializable
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)
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic longThe RD (Rata Die) number for the Persian calendar epoch.Fields inherited from class MonthDayYear
day, month, yearFields inherited from class SevenDaysWeek
DAY_NAMES, FRIDAY, MONDAY, SATURDAY, SUNDAY, THURSDAY, TUESDAY, WEDNESDAYFields inherited from class AlternateCalendar
JD_EPOCH, rd, unicode -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new PersianCalendar object.PersianCalendar(int i, int j, int k) Creates a new PersianCalendar object.PersianCalendar(long l) Creates a new PersianCalendar object.PersianCalendar(AlternateCalendar altcalendar) Creates a new PersianCalendar object. -
Method Summary
Modifier and TypeMethodDescriptionstatic longfixedFromPersian(long year, int month, int day) Computes the Rata Die number from the given Persian date.Returns an enumeration of all month names.protected StringReturns the suffix for Persian years ("A.P.").static booleanisLeapYear(int i) Checks if the given year is a leap year in the Persian calendar.static voidMain method for testing the Persian calendar implementation.protected StringReturns the name of the current month.protected voidRecomputes the month, day, and year from the current Rata Die number.protected voidRecomputes the Rata Die number from the current month, day, and year.voidset(long l) Sets the Rata Die number and recomputes the date.Methods inherited from class SevenDaysWeek
kDayAfter, kDayBefore, kDayNearest, kDayOnOrAfter, kDayOnOrBefore, nthKDay, weekDay, weekDayNameMethods inherited from class AlternateCalendar
add, amod, difference, difference, floorDiv, fromJD, isAfter, isBefore, mod, mod, subtract, toJD, toJD, toRD
-
Field Details
-
EPOCH
public static long EPOCHThe 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
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:
recomputeRDin classAlternateCalendar
-
recomputeFromRD
protected void recomputeFromRD()Recomputes the month, day, and year from the current Rata Die number.- Specified by:
recomputeFromRDin classAlternateCalendar
-
set
public void set(long l) Sets the Rata Die number and recomputes the date.- Specified by:
setin classAlternateCalendar- 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
Returns the name of the current month.- Specified by:
monthNamein classMonthDayYear- Returns:
- the month name string.
-
getSuffix
Returns the suffix for Persian years ("A.P.").- Specified by:
getSuffixin classMonthDayYear- Returns:
- the year suffix.
-
getMonths
Returns an enumeration of all month names.- Specified by:
getMonthsin classMonthDayYear- Returns:
- enumeration of month names.
-
main
Main method for testing the Persian calendar implementation.- Parameters:
args- command line arguments (year, month, day).
-