Class BadiCalendar

All Implemented Interfaces:
Serializable, Comparable<BadiCalendar>, CalendarDate, ChronoDisplay, Temporal<CalendarDate>

@CalendarType("bahai") public final class BadiCalendar extends Calendrical<BadiCalendar.Unit,​BadiCalendar>

Represents the calendar used by the Baha'i community.

The calendar composes 19 days to a month, 19 months to a year (plus an intercalary period called Ayyam-i-Ha between the 18th and the 19th month), 19 years to a vahid cycle and finally 19 vahids to a major cycle. Days start at sunset. And a week starts on Friday at sunset. The first year of the calendar begins on 1844-03-21. Years before 2015 start in this implementation always on 21st of March, but then on the day (from sunset to sunset in Teheran) which contains the vernal equinox. The latter change follows a decision made by the Universal House of Justice.

Following elements which are declared as constants are registered by this class:

Furthermore, all elements defined in EpochDays are supported.

Formatting and parsing: When using format patterns the dynamic pattern type is strongly recommended instead of CLDR-like pattern types because this calendar is structurally different from month-based calendars. Following symbol-element table holds:

Mapping of dynamic pattern symbols
elementsymboltype
ERAGtext
YEAR_OF_ERAy/Ynumber
KULL_I_SHAIk/Knumber
VAHIDv/Vnumber
YEAR_OF_VAHIDx/Xnumber/text
MONTH_OF_YEARm/Mnumber/text
AYYAM_I_HAAtext
DAY_OF_DIVISIONd/Dnumber
DAY_OF_WEEKEtext

It is strongly recommended to use the or-operator "|" in format patterns because not every date of this calendar has a month. Example:

     ChronoFormatter<BadiCalendar> f =
      ChronoFormatter.ofPattern(
          "k.v.x.m.d|k.v.x.A.d",
          PatternType.DYNAMIC,
          Locale.GERMAN,
          BadiCalendar.axis());
     assertThat(
      f.print(BadiCalendar.of(5, 11, BadiMonth.JALAL, 13)),
      is("1.5.11.2.13"));
     assertThat(
      f.print(BadiCalendar.ofIntercalary(5, 11, 2)),
      is("1.5.11.Aiyam-e Ha'.2"));
 
Since:
5.3
Author:
Meno Hochschild
See Also:
Serialized Form
  • Field Details

  • Method Details

    • ofComplete

      public static BadiCalendar ofComplete(int kullishay, int vahid, int yearOfVahid, BadiDivision division, int day)

      Creates a new instance of a Badi calendar date.

      Parameters:
      kullishay - major cycle of 361 years (only values 1, 2 or 3 are permitted)
      vahid - 19-year-cycle (in range 1-19)
      yearOfVahid - year in range 1-19
      division - either BadiMonth or BadiIntercalaryDays
      day - day in range 1-19 (1-4/5 in case of Ayyam-i-Ha)
      Returns:
      new instance of BadiCalendar
      Throws:
      IllegalArgumentException - in case of any inconsistencies
    • ofComplete

      public static BadiCalendar ofComplete(BadiEra era, int yearOfEra, BadiDivision division, int day)

      Creates a new instance of a Badi calendar date.

      Parameters:
      era - Bahai era
      yearOfEra - year of era in range 1-1083
      division - either BadiMonth or BadiIntercalaryDays
      day - day in range 1-19 (1-4/5 in case of Ayyam-i-Ha)
      Returns:
      new instance of BadiCalendar
      Throws:
      IllegalArgumentException - in case of any inconsistencies
    • of

      public static BadiCalendar of(int vahid, int yearOfVahid, BadiMonth month, int day)

      Creates a new instance of a Badi calendar date in first major cycle (gregorian years 1844-2204).

      Parameters:
      vahid - 19-year-cycle (in range 1-19)
      yearOfVahid - year in range 1-19
      month - Badi month
      day - day in range 1-19
      Returns:
      new instance of BadiCalendar
      Throws:
      IllegalArgumentException - in case of any inconsistencies
    • of

      public static BadiCalendar of(int vahid, int yearOfVahid, int month, int day)

      Creates a new instance of a Badi calendar date in first major cycle (gregorian years 1844-2204).

      Parameters:
      vahid - 19-year-cycle (in range 1-19)
      yearOfVahid - year in range 1-19
      month - month in range 1-19
      day - day in range 1-19
      Returns:
      new instance of BadiCalendar
      Throws:
      IllegalArgumentException - in case of any inconsistencies
    • ofIntercalary

      public static BadiCalendar ofIntercalary(int vahid, int yearOfVahid, int day)

      Creates a new instance of a Badi calendar date in first major cycle (gregorian years 1844-2204).

      Parameters:
      vahid - 19-year-cycle (in range 1-19)
      yearOfVahid - year in range 1-19
      day - day in range 1-4/5
      Returns:
      new instance of BadiCalendar in the Ayyam-i-Ha-period
      Throws:
      IllegalArgumentException - in case of any inconsistencies
    • nowInSystemTime

      public static BadiCalendar nowInSystemTime()

      Obtains the current calendar date in system time.

      Convenient short-cut for: SystemClock.inLocalView().now(BadiCalendar.axis()).

      Returns:
      current calendar date in system time zone using the system clock
      See Also:
      SystemClock.inLocalView(), ZonalClock.now(Chronology)
    • getKullishai

      public int getKullishai()

      Yields the major cycle (kull-i-shai) which is 361 years long.

      Returns:
      int
      See Also:
      KULL_I_SHAI
    • getVahid

      public int getVahid()

      Yields the 19-year-cycle (vahid = unity).

      Returns:
      int
      See Also:
      VAHID
    • getYearOfVahid

      public int getYearOfVahid()

      Yields the Badi year related to the vahid cycle.

      Returns:
      int (1-19)
      See Also:
      YEAR_OF_VAHID
    • getYearOfEra

      public int getYearOfEra()

      Yields the proleptic Badi year related to the Bahai era.

      Returns:
      int (1-1083)
      See Also:
      YEAR_OF_ERA
    • getMonth

      public BadiMonth getMonth()

      Yields the Badi month if available.

      Returns:
      month enum
      Throws:
      ChronoException - if this date is an intercalary day (Ayyam-i-Ha)
      See Also:
      MONTH_OF_YEAR, isIntercalaryDay(), hasMonth()
    • getDivision

      public BadiDivision getDivision()
      Obtains either the month or the Ayyam-i-Ha-period.
      Returns:
      BadiDivision
    • getDayOfDivision

      public int getDayOfDivision()

      Yields the day of either Badi month or Ayyam-i-Ha.

      Returns:
      int (1-4/5/19)
      See Also:
      DAY_OF_DIVISION
    • getDayOfWeek

      public Weekday getDayOfWeek()

      Determines the day of standard-week (with seven days).

      Returns:
      Weekday
      See Also:
      DAY_OF_WEEK
    • getDayOfYear

      public int getDayOfYear()

      Yields the day of year.

      Returns:
      int
      See Also:
      DAY_OF_YEAR
    • isIntercalaryDay

      public boolean isIntercalaryDay()

      Is this date an intercalary day?

      A date in the Badi calendar has either a month or is an intercalary day.

      Returns:
      boolean
      See Also:
      hasMonth(), BadiIntercalaryDays.AYYAM_I_HA
    • hasMonth

      public boolean hasMonth()

      Does this date contain a month?

      A date in the Badi calendar has either a month or is an intercalary day.

      Returns:
      boolean
      See Also:
      isIntercalaryDay()
    • isLeapYear

      public boolean isLeapYear()

      Is the year of this date a leap year?

      Returns:
      boolean
    • isLeapYear

      public static boolean isLeapYear(int kullishay, int vahid, int yearOfVahid)

      Is given Badi year a leap year?

      Parameters:
      kullishay - major cycle of 361 years (only values 1, 2 or 3 are permitted)
      vahid - 19-year-cycle (in range 1-19)
      yearOfVahid - year in range 1-19
      Returns:
      boolean
      Throws:
      IllegalArgumentException - in case of any inconsistencies
    • isValid

      public static boolean isValid(int kullishay, int vahid, int yearOfVahid, BadiDivision division, int day)

      Queries if given parameter values form a well defined calendar date.

      Parameters:
      kullishay - major cycle of 361 years (only values 1, 2 or 3 are permitted)
      vahid - 19-year-cycle (in range 1-19)
      yearOfVahid - year in range 1-19
      division - either BadiMonth or BadiIntercalaryDays
      day - day in range 1-19 (1-4/5 in case of Ayyam-i-Ha)
      Returns:
      true if valid else false
      See Also:
      ofComplete(int, int, int, BadiDivision, int)
    • at

      public GeneralTimestamp<BadiCalendar> at(PlainTime time)

      Creates a new local timestamp with this date and given wall time.

      If the time T24:00 is used then the resulting timestamp will automatically be normalized such that the timestamp will contain the following day instead.

      Parameters:
      time - wall time
      Returns:
      general timestamp as composition of this date and given time
    • atTime

      public GeneralTimestamp<BadiCalendar> atTime(int hour, int minute)

      Is equivalent to at(PlainTime.of(hour, minute)).

      Parameters:
      hour - hour of day in range (0-24)
      minute - minute of hour in range (0-59)
      Returns:
      general timestamp as composition of this date and given time
      Throws:
      IllegalArgumentException - if any argument is out of range
    • equals

      public boolean equals(Object obj)
      Description copied from class: Calendrical

      Based on the epoch day number and the calendar system.

      In other words: Two date object are equal if they have the same temporal position on the local timeline and have the same calendrical type. Subclasses which define further state attributes must override this method.

      If an only temporal comparison is required then the method Calendrical.isSimultaneous(CalendarDate) is to be used.

      Overrides:
      equals in class Calendrical<BadiCalendar.Unit,​BadiCalendar>
      See Also:
      Chronology.getChronoType()
    • hashCode

      public int hashCode()
      Description copied from class: Calendrical

      Based on the epoch day number.

      Overrides:
      hashCode in class Calendrical<BadiCalendar.Unit,​BadiCalendar>
    • toString

      public String toString()
      Description copied from class: TimePoint

      Provides a complete textual representation of the state of this time point.

      The textual description often follows the conventions of ISO-8601. Usually the description starts with the chronological informations which are coarse-grained and ends with those ones which are fine-grained (for example the ISO-notation YYYY-MM-DD).

      Specified by:
      toString in class TimePoint<BadiCalendar.Unit,​BadiCalendar>
    • contains

      public boolean contains(ChronoElement<?> element)
      Description copied from interface: ChronoDisplay

      Queries if the value for given chronological element can be accessed via get(element).

      If the argument is missing then this method will yield false. Note: Elements which are not registered but define a suitable rule are also accessible.

      Specified by:
      contains in interface ChronoDisplay
      Overrides:
      contains in class ChronoEntity<BadiCalendar>
      Parameters:
      element - chronological element to be asked (optional)
      Returns:
      true if the element is registered or there is an element rule for evaluating the value else false
      See Also:
      ChronoDisplay.get(ChronoElement)
    • isValid

      public <V> boolean isValid(ChronoElement<V> element, V value)
      Description copied from class: ChronoEntity

      Tests if the value for given chronological value is invalid.

      Notes: This method tests if given value to be in question can be set via the expression with(element, value). A numerical overflow situation (causing an ArithmeticException) will usually not be checked.

      Overrides:
      isValid in class ChronoEntity<BadiCalendar>
      Type Parameters:
      V - generic type of element value
      Parameters:
      element - element the given value shall be assigned to
      value - candidate value to be validated (optional)
      Returns:
      true if the method with() can be called without exception else false
      See Also:
      with(ChronoElement, V)
    • axis

      public static TimeAxis<BadiCalendar.Unit,​BadiCalendar> axis()

      Returns the associated time axis.

      Returns:
      chronology