@CalendarType(value="iso8601") public final class AnnualDate extends ChronoEntity<AnnualDate> implements Comparable<AnnualDate>, Temporal<AnnualDate>, ThreetenAdapter, LocalizedPatternSupport, Serializable
Represents a combination of month and day-of-month as XML-pendant for xsd:gMonthDay.
February, the 29th is always valid within the context of this class only.
Following elements which are declared as constants are registered by this class:
The calendar year is missing. Therefore this class cannot model a complete calendar date like
PlainDate. For the same reason, a temporal arithmetic is not defined. The main purpose
of this class is just modelling partial dates like birthdays etc. Formatting example for localized
formatting styles:
ChronoFormatter<AnnualDate> usStyle =
ChronoFormatter.ofStyle(DisplayMode.SHORT, Locale.US, AnnualDate.chronology());
ChronoFormatter<AnnualDate> germanStyle =
ChronoFormatter.ofStyle(DisplayMode.SHORT, Locale.GERMANY, AnnualDate.chronology());
System.out.println("US-format: " + usStyle.format(AnnualDate.of(9, 11))); // US-format: 9/11
System.out.println("German: " + germanStyle.format(AnnualDate.of(9, 11))); // German: 11.9.
Note: The current annual date can be determined by an expression like:
AnnualDate current = SystemClock.inLocalView().now(AnnualDate.chronology()).
| Modifier and Type | Field and Description |
|---|---|
static ChronoElement<Integer> |
DAY_OF_MONTH
Element with the day of month in the value range
1-28/29/30/31. |
static ChronoElement<Integer> |
MONTH_AS_NUMBER
Element with the calendar month in numerical form and the value range
1-12. |
static ChronoElement<Month> |
MONTH_OF_YEAR
Element with the calendar month as enum in the value range
JANUARY-DECEMBER). |
| Modifier and Type | Method and Description |
|---|---|
ChronoOperator<PlainDate> |
asNextExactEvent()
Determines the next possible exact annual date.
|
ChronoOperator<PlainDate> |
asNextRoundedEvent()
Determines the next possible annual date and rounds up to next day if necessary.
|
PlainDate |
atYear(int year)
Creates a complete ISO calendar date for given gregorian year.
|
static Chronology<AnnualDate> |
chronology()
Yields the associated chronology.
|
int |
compareTo(AnnualDate other) |
boolean |
equals(Object obj) |
static AnnualDate |
from(GregorianDate date)
Converts given gregorian date to an annual date.
|
static AnnualDate |
from(MonthDay monthDay)
Converts given JSR-310 type to an annual date.
|
int |
getDayOfMonth()
Obtains the day of month.
|
Month |
getMonth()
Obtains the gregorian month.
|
int |
hashCode() |
boolean |
isAfter(AnnualDate temporal)
Queries if this object is after given object on a timeline.
|
boolean |
isBefore(AnnualDate temporal)
Queries if this object is before given object on a timeline.
|
boolean |
isSimultaneous(AnnualDate temporal)
Queries if this object and given object have the same position
on the time axis.
|
boolean |
isValidDate(int year)
Checks if this instance results in a valid ISO calendar date for given gregorian year.
|
static AnnualDate |
nowInSystemTime()
Obtains the current annual date in system time.
|
static AnnualDate |
of(int month,
int dayOfMonth)
Creates a new annual date.
|
static AnnualDate |
of(Month month,
int dayOfMonth)
Creates a new annual date.
|
static AnnualDate |
parseXML(String xml)
Parses given string to an annual date where the input is in XML-format "--MM-dd".
|
static Chronology<MonthDay> |
threeten()
Obtains a bridge chronology for the type
java.time.MonthDay. |
String |
toString()
Yields the full description in the XML-format "--MM-dd".
|
MonthDay |
toTemporalAccessor()
Converts this object to a
TemporalAccessor. |
contains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withisAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqualget, getLong, isSupported, query, rangegetFormatPattern, getFormatPattern, useDynamicFormatPattern@FormattableElement(format="M", alt="L") public static final ChronoElement<Month> MONTH_OF_YEAR
Element with the calendar month as enum in the value range JANUARY-DECEMBER).
public static final ChronoElement<Integer> MONTH_AS_NUMBER
Element with the calendar month in numerical form and the value range
1-12.
Normally the enum-variant is recommended due to clarity and type-safety. The enum-form can also be formatted as text.
MONTH_OF_YEAR@FormattableElement(format="d") public static final ChronoElement<Integer> DAY_OF_MONTH
Element with the day of month in the value range 1-28/29/30/31.
public static AnnualDate of(Month month, int dayOfMonth)
Creates a new annual date.
month - gregorian month as enumdayOfMonth - the day of month in range 1-29/30/31public static AnnualDate of(int month, int dayOfMonth)
Creates a new annual date.
month - gregorian month in range 1-12dayOfMonth - the day of month in range 1-29/30/31public static AnnualDate from(GregorianDate date)
Converts given gregorian date to an annual date.
date - gregorian calendar date (for example PlainDateIllegalArgumentException - if given date is invalidpublic static AnnualDate from(MonthDay monthDay)
Converts given JSR-310 type to an annual date.
monthDay - JSR-310-equivalenttoTemporalAccessor()public static AnnualDate nowInSystemTime()
Obtains the current annual date in system time.
Convenient short-cut for: SystemClock.inLocalView().now(AnnualDate.chronology()).
SystemClock.inLocalView(),
ZonalClock.now(net.time4j.engine.Chronology)public Month getMonth()
Obtains the gregorian month.
public int getDayOfMonth()
Obtains the day of month.
public boolean isAfter(AnnualDate temporal)
TemporalQueries if this object is after given object on a timeline.
isAfter in interface Temporal<AnnualDate>temporal - object this instance is compared totrue if this instance is temporally after
temporal else falsepublic boolean isBefore(AnnualDate temporal)
TemporalQueries if this object is before given object on a timeline.
isBefore in interface Temporal<AnnualDate>temporal - object this instance is compared totrue if this instance is temporally before
temporal else falsepublic boolean isSimultaneous(AnnualDate temporal)
TemporalQueries if this object and given object have the same position on the time axis.
Is equivalent to !isAfter(temporal) && !isBefore(temporal).
This method differs from the Object-method equals()
such that first the comparison type must be a temporal one and second
that only temporal-only state will be considered.
isSimultaneous in interface Temporal<AnnualDate>temporal - object this instance is compared totrue if this instance is temporally equal
to temporal else falsepublic int compareTo(AnnualDate other)
compareTo in interface Comparable<AnnualDate>public String toString()
Yields the full description in the XML-format "--MM-dd".
toString in class ObjectparseXML(String)public static AnnualDate parseXML(String xml) throws ParseException
Parses given string to an annual date where the input is in XML-format "--MM-dd".
xml - string compatible to lexical space of xsd:gMonthDayParseException - if parsing failstoString()public PlainDate atYear(int year)
Creates a complete ISO calendar date for given gregorian year.
year - proleptic iso year [(-999,999,999)-999,999,999]IllegalArgumentException - if the year argument is out of range or if this instance represents
the 29th of February and is not valid for given yearisValidDate(int)public boolean isValidDate(int year)
Checks if this instance results in a valid ISO calendar date for given gregorian year.
year - proleptic iso year [(-999,999,999)-999,999,999]true if the year argument is out of range or if this instance represents
the 29th of February and is not valid for given year else falseatYear(int)public MonthDay toTemporalAccessor()
ThreetenAdapterConverts this object to a TemporalAccessor.
Any implementation is required to return a new object with a different concrete type, not this instance.
toTemporalAccessor in interface ThreetenAdapterpublic ChronoOperator<PlainDate> asNextExactEvent()
Determines the next possible exact annual date.
If this annual date is a leap day then the next date can be some years later. Example:
System.out.println(PlainDate.of(2015, 2, 28).with(AnnualDate.of(Month.FEBRUARY, 29).asNextEvent()));
// 2016-02-29
System.out.println(PlainDate.of(2016, 2, 28).with(AnnualDate.of(Month.FEBRUARY, 29).asNextEvent()));
// 2016-02-29
System.out.println(PlainDate.of(2016, 2, 29).with(AnnualDate.of(Month.FEBRUARY, 29).asNextEvent()));
// 2020-02-29
asNextRoundedEvent()public ChronoOperator<PlainDate> asNextRoundedEvent()
Determines the next possible annual date and rounds up to next day if necessary.
If this annual date is a leap day then the next date can be advanced to begin of March. Example:
System.out.println(PlainDate.of(2015, 2, 28).with(AnnualDate.of(Month.FEBRUARY, 29).asNextEvent()));
// 2015-03-01
asNextExactEvent()public static Chronology<AnnualDate> chronology()
Yields the associated chronology.
public static Chronology<MonthDay> threeten()
Obtains a bridge chronology for the type java.time.MonthDay.
java.time.MonthDaychronology()Copyright © 2014–2021. All rights reserved.