Enum Class PersianAlgorithm
- All Implemented Interfaces:
Serializable
,Comparable<PersianAlgorithm>
,java.lang.constant.Constable
Enumeration of different calculation methods for the Persian calendar.
- Since:
- 3.33/4.28
- Author:
- Meno Hochschild
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionBased on the astronomical calculation of vernal equinox as start of Persian year usually in the Iranian Standard time.A popular proposal of Ahmad Birashk which uses a complex system of cycles and grand cycles.Based on the work of the Polish astronomer Kazimierz Borkowski.Uses a 33-year-cycle to determine a simple leap year rule (discovered by Omar Khayyam). -
Method Summary
Modifier and TypeMethodDescriptionstatic AttributeKey<PersianAlgorithm>
Format attribute which helps to resolve algorithmic differences between various Persian dates.boolean
isLeapYear(int persianYear)
Determines if given persian year is a leap year.static PersianAlgorithm
Returns the enum constant of this class with the specified name.static PersianAlgorithm[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
BORKOWSKI
Based on the work of the Polish astronomer Kazimierz Borkowski.
This is the default and uses a refinement of the Khayyam 33-year-rule based on astronomical calculations for the Teheran mean time. However, users should keep following things in mind when discussing the possible errors:
- Borkowski uses the offset of
+03:25:30
which deviates from the Iranian Standard Time+03:30
. In addition, it is questionable if the historic ancestor of the Persian calendar has used any of these offsets in ancient times. - The astronomical calculations are not published in detail but seem to deviate by several minutes in the far past or future compared with what we can derive from the work of the Belgian astronomer Jean Meeus.
- The delta-T-calculation is somehow simplistic compared with the more accurate formulas used in Time4J.
- The mean solar time is used. It is for debate if the Persian calendar is rather based on the apparent solar time.
- Borkowski uses the offset of
-
KHAYYAM
Uses a 33-year-cycle to determine a simple leap year rule (discovered by Omar Khayyam).
If the remainder of the division of persian year by 33 is one of following numbers then and only then it is a leap year: 1, 5, 9, 13, 17, 22, 26, 30. The rule is correct for the Persian years 1178-1633 (gregorian: 1799-2254).
-
BIRASHK
A popular proposal of Ahmad Birashk which uses a complex system of cycles and grand cycles.
It works for most years but sometimes it is not in agreement with the astronomical nature of the Persian calendar. For example, the year 2025 (gregorian) is expected to break this rule.
-
ASTRONOMICAL
Based on the astronomical calculation of vernal equinox as start of Persian year usually in the Iranian Standard time.
The implementation works as follows:
- The vernal equinox is evaluated by
AstronomicalSeason.inYear(int)
. - The time zone offset is chosen as
UTC+03:30
if not specified otherwise. - If the apparent vernal equinox is after noon then the next day is the start of Persian year.
- The maximum supported Persian year is 2378.
- The vernal equinox is evaluated by
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
attribute
Format attribute which helps to resolve algorithmic differences between various Persian dates.
Following example demonstrates the difference between the standard algorithm and the algorithm proposed by A. Birashk:
PersianCalendar pcal = PersianCalendar.of(1403, 12, 30); // = 2025-03-20 (gregorian) ChronoFormatter<PersianCalendar> f = ChronoFormatter .ofPattern("dd.MM.yyyy G", PatternType.CLDR, Locale.ROOT, PersianCalendar.axis()) .with(PersianAlgorithm.attribute(), PersianAlgorithm.BIRASHK); assertThat(f.parse("01.01.1404 AP"), is(pcal)); assertThat(f.format(pcal), is("01.01.1404 AP"));
Standard value is:
BORKOWSKI
. It is also possible to use theastronomical algorithm
in combination with an arbitrary timezone offset by setting the format attributeAttributes.TIMEZONE_ID
to anyZonalOffset
.- Returns:
- format attribute key
-
isLeapYear
public boolean isLeapYear(int persianYear)Determines if given persian year is a leap year.
- Parameters:
persianYear
- the persian year to be queried- Returns:
true
if the year is a leap year elsefalse
- Throws:
IllegalArgumentException
- if the year is out of range 1-3000
-