Class BadiCalendar
- All Implemented Interfaces:
Serializable
,Comparable<BadiCalendar>
,CalendarDate
,ChronoDisplay
,Temporal<CalendarDate>
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:
DAY_OF_DIVISION
DAY_OF_WEEK
DAY_OF_YEAR
AYYAM_I_HA
MONTH_OF_YEAR
YEAR_OF_VAHID
VAHID
KULL_I_SHAI
YEAR_OF_ERA
ERA
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:
element | symbol | type |
---|---|---|
ERA | G | text |
YEAR_OF_ERA | y/Y | number |
KULL_I_SHAI | k/K | number |
VAHID | v/V | number |
YEAR_OF_VAHID | x/X | number/text |
MONTH_OF_YEAR | m/M | number/text |
AYYAM_I_HA | A | text |
DAY_OF_DIVISION | d/D | number |
DAY_OF_WEEK | E | text |
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Defines come calendar units for the Badi calendar. -
Field Summary
Modifier and TypeFieldDescriptionstatic ChronoElement<BadiIntercalaryDays>
Represents the period of intercalary days if available.static StdCalendarElement<Integer,BadiCalendar>
Represents the day of month or an intercalary day.static StdCalendarElement<Weekday,BadiCalendar>
Represents the day of week.static StdCalendarElement<Integer,BadiCalendar>
Represents the day of year.static ChronoElement<BadiEra>
Represents the Bahai era.static ChronoElement<Integer>
Represents the major cycle (kull-i-shai).static StdCalendarElement<BadiMonth,BadiCalendar>
Represents the month if available.static AttributeKey<FormattedContent>
Format attribute which controls the content of some text elements like months or weekdays.static StdCalendarElement<Integer,BadiCalendar>
Represents the vahid cycle which consists of 19 years.static StdCalendarElement<Integer,BadiCalendar>
Represents the proleptic year of era (relative to gregorian year 1844).static TextElement<Integer>
Represents the year of vahid cycle. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new local timestamp with this date and given wall time.atTime(int hour, int minute)
Is equivalent toat(PlainTime.of(hour, minute))
.static TimeAxis<BadiCalendar.Unit,BadiCalendar>
axis()
Returns the associated time axis.boolean
contains(ChronoElement<?> element)
Queries if the value for given chronological element can be accessed viaget(element)
.boolean
Based on the epoch day number and the calendar system.int
Yields the day of either Badi month or Ayyam-i-Ha.Determines the day of standard-week (with seven days).int
Yields the day of year.Obtains either the month or the Ayyam-i-Ha-period.int
Yields the major cycle (kull-i-shai) which is 361 years long.getMonth()
Yields the Badi month if available.int
getVahid()
Yields the 19-year-cycle (vahid = unity).int
Yields the proleptic Badi year related to the Bahai era.int
Yields the Badi year related to the vahid cycle.int
hashCode()
Based on the epoch day number.boolean
hasMonth()
Does this date contain a month?boolean
Is this date an intercalary day?boolean
Is the year of this date a leap year?static boolean
isLeapYear(int kullishay, int vahid, int yearOfVahid)
Is given Badi year a leap year?static boolean
isValid(int kullishay, int vahid, int yearOfVahid, BadiDivision division, int day)
Queries if given parameter values form a well defined calendar date.<V> boolean
isValid(ChronoElement<V> element, V value)
Tests if the value for given chronological value is invalid.static BadiCalendar
Obtains the current calendar date in system time.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).static BadiCalendar
Creates a new instance of a Badi calendar date in first major cycle (gregorian years 1844-2204).static BadiCalendar
ofComplete(int kullishay, int vahid, int yearOfVahid, BadiDivision division, int day)
Creates a new instance of a Badi calendar date.static BadiCalendar
ofComplete(BadiEra era, int yearOfEra, BadiDivision division, int day)
Creates a new instance of a Badi calendar date.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).toString()
Provides a complete textual representation of the state of this time point.Methods inherited from class net.time4j.engine.Calendrical
compareTo, getDaysSinceEpochUTC, isAfter, isBefore, isSimultaneous, minus, plus
Methods inherited from class net.time4j.engine.TimePoint
max, min, minus, minus, plus, plus, until, until
Methods inherited from class net.time4j.engine.ChronoEntity
get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, matches, with, with, with, with
Methods inherited from interface net.time4j.engine.CalendarDate
transform, transform, transform, transform, transform, transform
Methods inherited from interface net.time4j.engine.Temporal
isAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual
-
Field Details
-
TEXT_CONTENT_ATTRIBUTE
Format attribute which controls the content of some text elements like months or weekdays.Standard value is:
FormattedContent.TRANSCRIPTION
. Example:ChronoFormatter<BadiCalendar> f = ChronoFormatter .ofPattern( "k-v-x-MMMM-d|k-v-x-A-d", PatternType.DYNAMIC, Locale.ENGLISH, BadiCalendar.axis()) .with(BadiCalendar.TEXT_CONTENT_ATTRIBUTE, FormattedContent.HTML); System.out.println(f.print(BadiCalendar.of(5, 11, BadiMonth.MASHIYYAT, 15)));
Output with underlined sh: "1-5-11-Mashíyyat-15"
- See Also:
YEAR_OF_VAHID
,MONTH_OF_YEAR
,DAY_OF_WEEK
-
ERA
Represents the Bahai era.
-
YEAR_OF_ERA
@FormattableElement(format="Y", alt="y", dynamic=true) public static final StdCalendarElement<Integer,BadiCalendar> YEAR_OF_ERARepresents the proleptic year of era (relative to gregorian year 1844).
Note that this kind of year definition which counts years since the Bahai era deviates from the. 19-cycle. For the standard way to count years see the elements
KULL_I_SHAI
,VAHID
andYEAR_OF_VAHID
. -
KULL_I_SHAI
@FormattableElement(format="K", alt="k", dynamic=true) public static final ChronoElement<Integer> KULL_I_SHAIRepresents the major cycle (kull-i-shai).
This calendar supports the values 1-3. However, only the first major cycle can be interpreted as safe while the higher values are an astronomic approximation.
-
VAHID
@FormattableElement(format="V", alt="v", dynamic=true) public static final StdCalendarElement<Integer,BadiCalendar> VAHIDRepresents the vahid cycle which consists of 19 years.
-
YEAR_OF_VAHID
@FormattableElement(format="X", alt="x", dynamic=true) public static final TextElement<Integer> YEAR_OF_VAHIDRepresents the year of vahid cycle.
The dynamic pattern symbol X or x will print the year of vahid either as text (big symbol letter) or as number (small symbol letter).
-
MONTH_OF_YEAR
@FormattableElement(format="M", alt="m", dynamic=true) public static final StdCalendarElement<BadiMonth,BadiCalendar> MONTH_OF_YEARRepresents the month if available.
Warning: A Badi date does not always have a month. If the date is an intercalary day (Ayyam-i-Ha) then any access via
get(MONTH_OF_YEAR)
to this element will be rejected by raising an exception. Users have first to make sure that the date is not such an intercalary day.However, it is always possible to query the date for the minimum or maximum month or to set the date to a month-related day even if the actual date is an intercalary day.
- See Also:
isIntercalaryDay()
,hasMonth()
-
AYYAM_I_HA
@FormattableElement(format="A", dynamic=true) public static final ChronoElement<BadiIntercalaryDays> AYYAM_I_HARepresents the period of intercalary days if available.
Warning: A Badi date often does not have such a period. If the date is not an intercalary day (Ayyam-i-Ha) then any access via
get(AYYAM_I_HA)
to this element will be rejected by raising an exception. Users have first to make sure that the date is such an intercalary day.This element cannot be formatted in a numeric way but only as text. Therefore the dynamic format symbol A is only permitted as big letter.
- See Also:
isIntercalaryDay()
,hasMonth()
-
DAY_OF_DIVISION
@FormattableElement(format="D", alt="d", dynamic=true) public static final StdCalendarElement<Integer,BadiCalendar> DAY_OF_DIVISIONRepresents the day of month or an intercalary day.
-
DAY_OF_YEAR
Represents the day of year.
-
DAY_OF_WEEK
@FormattableElement(format="E", dynamic=true) public static final StdCalendarElement<Weekday,BadiCalendar> DAY_OF_WEEKRepresents the day of week.
If the day-of-week is set to a new value then Time4J handles the calendar week as starting on Saturday.
-
-
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-19division
- eitherBadiMonth
orBadiIntercalaryDays
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
Creates a new instance of a Badi calendar date.
- Parameters:
era
- Bahai erayearOfEra
- year of era in range 1-1083division
- eitherBadiMonth
orBadiIntercalaryDays
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
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-19month
- Badi monthday
- day in range 1-19- Returns:
- new instance of
BadiCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies
-
of
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-19month
- month in range 1-19day
- day in range 1-19- Returns:
- new instance of
BadiCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies
-
ofIntercalary
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-19day
- 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
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
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
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
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-19division
- eitherBadiMonth
orBadiIntercalaryDays
day
- day in range 1-19 (1-4/5 in case of Ayyam-i-Ha)- Returns:
true
if valid elsefalse
- See Also:
ofComplete(int, int, int, BadiDivision, int)
-
at
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
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
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 classCalendrical<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 classCalendrical<BadiCalendar.Unit,BadiCalendar>
-
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 classTimePoint<BadiCalendar.Unit,BadiCalendar>
-
contains
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 interfaceChronoDisplay
- Overrides:
contains
in classChronoEntity<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 elsefalse
- See Also:
ChronoDisplay.get(ChronoElement)
-
isValid
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 anArithmeticException
) will usually not be checked.- Overrides:
isValid
in classChronoEntity<BadiCalendar>
- Type Parameters:
V
- generic type of element value- Parameters:
element
- element the given value shall be assigned tovalue
- candidate value to be validated (optional)- Returns:
true
if the methodwith()
can be called without exception elsefalse
- See Also:
with(ChronoElement, V)
-
axis
Returns the associated time axis.
- Returns:
- chronology
-