@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(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) |
boolean |
isBefore(AnnualDate temporal) |
boolean |
isSimultaneous(AnnualDate temporal) |
boolean |
isValidDate(int year)
Checks if this instance results in a valid ISO calendar date for given gregorian year.
|
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() |
contains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withisAfterAll, isBeforeAllget, getLong, isSupported, query, range@FormattableElement(format="M", standalone="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(MonthDay monthDay)
Converts given JSR-310 type to an annual date.
monthDay - JSR-310-equivalenttoTemporalAccessor()public Month getMonth()
Obtains the gregorian month.
public int getDayOfMonth()
Obtains the day of month.
public boolean isAfter(AnnualDate temporal)
isAfter in interface Temporal<AnnualDate>public boolean isBefore(AnnualDate temporal)
isBefore in interface Temporal<AnnualDate>public boolean isSimultaneous(AnnualDate temporal)
isSimultaneous in interface Temporal<AnnualDate>public 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()
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–2016. All rights reserved.