Enum Class PersianAlgorithm

All Implemented Interfaces:
Serializable, Comparable<PersianAlgorithm>, java.lang.constant.Constable

public enum PersianAlgorithm extends Enum<PersianAlgorithm>

Enumeration of different calculation methods for the Persian calendar.

Meno Hochschild
  • Enum Constant Details


      public static final PersianAlgorithm 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.

      public static final PersianAlgorithm 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).


      public static final PersianAlgorithm 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.


      public static final PersianAlgorithm 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.
  • Method Details

    • values

      public static PersianAlgorithm[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static PersianAlgorithm valueOf(String name)
      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.)
      name - the name of the enum constant to be returned.
      the enum constant with the specified name
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • attribute

      public static AttributeKey<PersianAlgorithm> 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 =
                    .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 the astronomical algorithm in combination with an arbitrary timezone offset by setting the format attribute Attributes.TIMEZONE_ID to any ZonalOffset.

      format attribute key
    • isLeapYear

      public boolean isLeapYear(int persianYear)

      Determines if given persian year is a leap year.

      persianYear - the persian year to be queried
      true if the year is a leap year else false
      IllegalArgumentException - if the year is out of range 1-3000