public static final class PersianCalendar.Date extends Object implements ChronoDisplay
Static view of calendar date taking into account possibly different calendar algorithms.
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)
PersianCalendar.Date birashk = pcal.getDate(PersianAlgorithm.BIRASHK); // AP-1404-01-01[BIRASHK]
assertThat(birashk.get(PersianCalendar.YEAR_OF_ERA), is(Integer.valueOf(1404)));
assertThat(birashk.getInt(PersianCalendar.YEAR_OF_ERA), is(1404));
assertThat(birashk.get(PersianCalendar.MONTH_OF_YEAR), is(PersianMonth.FARVARDIN));
assertThat(birashk.getInt(PersianCalendar.DAY_OF_MONTH), is(1));
assertThat(birashk.getInt(PersianCalendar.DAY_OF_YEAR), is(1));
assertThat(birashk.get(PersianCalendar.DAY_OF_WEEK), is(pcal.getDayOfWeek()));
assertThat(birashk.getMaximum(PersianCalendar.DAY_OF_MONTH), is(31));
assertThat(birashk.getMaximum(PersianCalendar.DAY_OF_YEAR), is(366));
Note: Only elements registered in the Persian calendar chronology are supported.
PersianCalendar.getDate(PersianAlgorithm),
PersianCalendar.getDate(ZonalOffset),
PersianAlgorithm.attribute()| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(ChronoElement<?> element)
Queries if the value for given chronological element can be
accessed via
get(element). |
boolean |
equals(Object obj) |
<V> V |
get(ChronoElement<V> element)
Returns the partial value associated with given chronological
element.
|
int |
getInt(ChronoElement<Integer> element)
Returns the partial value associated with given chronological element.
|
<V> V |
getMaximum(ChronoElement<V> element)
Yields the maximum value of given chronological element in the
current context of this object.
|
<V> V |
getMinimum(ChronoElement<V> element)
Yields the minimum value of given chronological element in the
current context of this object.
|
ZonalOffset |
getTimezone()
If the underlying algorithm is
PersianAlgorithm.ASTRONOMICAL then
this method will yield the timezone offset, usually Teheran Standard Time. |
int |
hashCode() |
boolean |
hasTimezone()
This date can only have a timezone (offset) if the underlying algorithm is
PersianAlgorithm.ASTRONOMICAL. |
String |
toString() |
public boolean contains(ChronoElement<?> element)
ChronoDisplayQueries 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.
contains in interface ChronoDisplayelement - chronological element to be asked (optional)true if the element is registered or there is an element rule for evaluating the value
else falseChronoDisplay.get(ChronoElement)public <V> V get(ChronoElement<V> element)
ChronoDisplayReturns the partial value associated with given chronological element.
get in interface ChronoDisplayV - generic type of element valueelement - element which has the valuenull)ChronoDisplay.contains(ChronoElement)public int getInt(ChronoElement<Integer> element)
ChronoDisplayReturns the partial value associated with given chronological element.
getInt in interface ChronoDisplayelement - element which has the valueInteger.MIN_VALUE if not availableChronoDisplay.get(ChronoElement)public <V> V getMinimum(ChronoElement<V> element)
ChronoDisplayYields the minimum value of given chronological element in the current context of this object.
The definition of a minimum and a maximum does generally not imply that every intermediate value between minimum and maximum is valid in this context. For example in the timezone Europe/Berlin the hour [T02:00] will be invalid if switching to summer time.
In most cases the minimum value is not dependent on this context.
getMinimum in interface ChronoDisplayV - generic type of element valueelement - element whose minimum value is to be evaluatedChronoElement.getDefaultMinimum(),
ChronoDisplay.getMaximum(ChronoElement)public <V> V getMaximum(ChronoElement<V> element)
ChronoDisplayYields the maximum value of given chronological element in the current context of this object.
Maximum values are different from minimum case often dependent
on the context. An example is the element SECOND_OF_MINUTE whose
maximum is normally 59 but can differ in UTC-context with
leap seconds. Another more common example is the maximum of the
element DAY_OF_MONTH (28-31) which is dependent on the month and year
of this context (leap years!).
Note: In timezone-related timestamps possible offset jumps inducing gaps on the local timeline will be conserved. That means that minimum and maximum do not guarantee a continuum of valid intermediate values.
getMaximum in interface ChronoDisplayV - generic type of element valueelement - element whose maximum value is to be evaluatedChronoElement.getDefaultMaximum(),
ChronoDisplay.getMinimum(ChronoElement)public boolean hasTimezone()
This date can only have a timezone (offset) if the underlying algorithm is
PersianAlgorithm.ASTRONOMICAL.
hasTimezone in interface ChronoDisplaypublic ZonalOffset getTimezone()
If the underlying algorithm is PersianAlgorithm.ASTRONOMICAL then
this method will yield the timezone offset, usually Teheran Standard Time.
getTimezone in interface ChronoDisplayChronoException - if the algorithm is not astronomicalChronoDisplay.hasTimezone()Copyright © 2014–2021. All rights reserved.