@CalendarType(value="iso8601") public final class CalendarMonth extends FixedCalendarInterval<CalendarMonth> implements ThreetenAdapter, LocalizedPatternSupport
Represents the month of a gregorian calendar year as interval (like from 1st of January until end of January).
The elements registered by this class are:
Formatting example for localized styles:
ChronoFormatter<CalendarMonth> usStyle =
ChronoFormatter.ofStyle(DisplayMode.SHORT, Locale.US, CalendarMonth.chronology());
ChronoFormatter<CalendarMonth> germanStyle =
ChronoFormatter.ofStyle(DisplayMode.SHORT, Locale.GERMANY, CalendarMonth.chronology());
System.out.println("US-format: " + usStyle.format(CalendarMonth.of(2016, 5))); // US-format: 5/2016
System.out.println("German: " + germanStyle.format(CalendarMonth.of(2016, 5))); // German: 5.2016
Note: The current month of calendar year can be determined by an expression like:
nowInSystemTime() or in a more general way
CalendarMonth current = SystemClock.inLocalView().now(CalendarMonth.chronology()).
| Modifier and Type | Field and Description |
|---|---|
static ChronoElement<Integer> |
MONTH_AS_NUMBER
Element with the month as number in the value range
1 - 12. |
static ChronoElement<Month> |
MONTH_OF_YEAR
Element with the month of year in the value range
January - December. |
static ChronoElement<Integer> |
YEAR
Element with the proleptic iso-year without any era reference and
the value range
-999999999 until 999999999. |
| Modifier and Type | Method and Description |
|---|---|
PlainDate |
atDayOfMonth(int dayOfMonth)
Combines this year and month with given day of month to a calendar date.
|
PlainDate |
atEndOfMonth()
Yields the date of the end of this calendar month.
|
static Chronology<CalendarMonth> |
chronology()
Yields the associated chronology.
|
int |
compareTo(CalendarMonth other) |
boolean |
contains(PlainDate temporal)
Queries if given time point belongs to this interval.
|
boolean |
equals(Object obj) |
static CalendarMonth |
from(GregorianDate date)
Converts given gregorian date to a calendar month.
|
static CalendarMonth |
from(YearMonth yearMonth)
Converts given JSR-310-type to a calendar month.
|
Boundary<PlainDate> |
getEnd()
Yields the upper bound of this interval.
|
Month |
getMonth()
Yields the month as enum.
|
Boundary<PlainDate> |
getStart()
Yields the lower bound of this interval.
|
int |
getYear()
Yields the year number.
|
int |
hashCode() |
boolean |
isAfter(PlainDate temporal)
Is this interval after the given time point?
|
boolean |
isBefore(PlainDate temporal)
Is this interval before the given time point?
|
Iterator<PlainDate> |
iterator()
Iterates over all days of this calendar month.
|
int |
length()
Ermittelt die Anzahl der Tage, die zu diesem Kalendermonat gehören.
|
CalendarMonth |
minus(Months months)
Subtracts given months from this calendar month.
|
CalendarMonth |
minus(Years<CalendarUnit> years)
Subtracts given years from this calendar month.
|
static CalendarMonth |
nowInSystemTime()
Obtains the current calendar month in system time.
|
static CalendarMonth |
of(int year,
int month)
Creates a new instance based on given gregorian calendar year and month.
|
static CalendarMonth |
of(int year,
Month month)
Creates a new instance based on given gregorian calendar year and month.
|
static CalendarMonth |
parseISO(String text)
Interpretes given ISO-conforming text as calendar month.
|
CalendarMonth |
plus(Months months)
Adds given months to this calendar month.
|
CalendarMonth |
plus(Years<CalendarUnit> years)
Adds given years to this calendar month.
|
static Chronology<YearMonth> |
threeten()
Obtains a bridge chronology for the type
java.time.YearMonth. |
String |
toString()
Outputs this instance as a String in CLDR-format "uuuu-MM" (like "2016-10").
|
YearMonth |
toTemporalAccessor() |
abuts, contains, isBefore, isEmpty, isFinite, isSimultaneous, streamDaily, toFlexInterval, withValuecontains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withget, getLong, isSupported, query, rangeintersects, isAfterforEach, spliterator@FormattableElement(format="u") public static final ChronoElement<Integer> YEAR
Element with the proleptic iso-year without any era reference and
the value range -999999999 until 999999999.
The term "proleptic" means that the rules of the gregorian
calendar and the associated way of year counting is applied backward
even before the introduction of gregorian calendar. The year 0
is permitted - and negative years, too. For historic year numbers,
this mathematical extrapolation is not recommended and usually
wrong.
@FormattableElement(format="M", standalone="L") public static final ChronoElement<Month> MONTH_OF_YEAR
Element with the month of year in the value range
January - December.
public static final ChronoElement<Integer> MONTH_AS_NUMBER
Element with the month as number in the value range 1 - 12.
public static CalendarMonth of(int year, int month)
Creates a new instance based on given gregorian calendar year and month.
year - gregorian year within range -999,999,999 / +999,999,999month - gregorian month in range 1-12IllegalArgumentException - if any argument is out of rangepublic static CalendarMonth of(int year, Month month)
Creates a new instance based on given gregorian calendar year and month.
year - gregorian year within range -999,999,999 / +999,999,999month - gregorian monthIllegalArgumentException - if given year is out of rangepublic static CalendarMonth nowInSystemTime()
Obtains the current calendar month in system time.
Convenient short-cut for: SystemClock.inLocalView().now(CalendarMonth.chronology()).
SystemClock.inLocalView(),
ZonalClock.now(net.time4j.engine.Chronology)public PlainDate atDayOfMonth(int dayOfMonth)
Combines this year and month with given day of month to a calendar date.
dayOfMonth - day of month in range 1-28/29/30/31IllegalArgumentException - if the day-of-month is out of rangepublic PlainDate atEndOfMonth()
Yields the date of the end of this calendar month.
public int getYear()
Yields the year number.
public Month getMonth()
Yields the month as enum.
User who wish to get the month as integer can use the expression getMonth().getValue().
public Boundary<PlainDate> getStart()
ChronoIntervalYields the lower bound of this interval.
getStart in interface ChronoInterval<PlainDate>public Boundary<PlainDate> getEnd()
ChronoIntervalYields the upper bound of this interval.
getEnd in interface ChronoInterval<PlainDate>public boolean contains(PlainDate temporal)
ChronoIntervalQueries if given time point belongs to this interval.
contains in interface ChronoInterval<PlainDate>temporal - time point to be queriedtrue if given time point belongs to this interval else falsepublic boolean isAfter(PlainDate temporal)
ChronoIntervalIs this interval after the given time point?
isAfter in interface ChronoInterval<PlainDate>temporal - reference time pointtrue if this interval is after given time point else falsepublic boolean isBefore(PlainDate temporal)
ChronoIntervalIs this interval before the given time point?
isBefore in interface ChronoInterval<PlainDate>temporal - reference time pointtrue if this interval is before given time point else falsepublic int length()
Ermittelt die Anzahl der Tage, die zu diesem Kalendermonat gehören.
public static CalendarMonth from(GregorianDate date)
Converts given gregorian date to a calendar month.
date - gregorian calendar date (for example PlainDateIllegalArgumentException - if given date is invalidpublic static CalendarMonth from(YearMonth yearMonth)
Converts given JSR-310-type to a calendar month.
yearMonth - Threeten-equivalent of this instancetoTemporalAccessor()public CalendarMonth plus(Years<CalendarUnit> years)
Adds given years to this calendar month.
years - the count of years to be addedpublic CalendarMonth plus(Months months)
Adds given months to this calendar month.
months - the count of months to be addedpublic CalendarMonth minus(Years<CalendarUnit> years)
Subtracts given years from this calendar month.
years - the count of years to be subtractedpublic CalendarMonth minus(Months months)
Subtracts given months from this calendar month.
months - the count of months to be subtractedpublic int compareTo(CalendarMonth other)
compareTo in interface Comparable<CalendarMonth>public String toString()
Outputs this instance as a String in CLDR-format "uuuu-MM" (like "2016-10").
toString in class ObjectparseISO(String)public static CalendarMonth parseISO(String text) throws ParseException
Interpretes given ISO-conforming text as calendar month.
The underlying parser uses the CLDR-pattern "uuuu-MM|uuuuMM".
text - text to be parsedIndexOutOfBoundsException - if given text is emptyParseException - if the text is not parseabletoString()public YearMonth toTemporalAccessor()
toTemporalAccessor in interface ThreetenAdapterpublic static Chronology<CalendarMonth> chronology()
Yields the associated chronology.
public static Chronology<YearMonth> threeten()
Obtains a bridge chronology for the type java.time.YearMonth.
java.time.YearMonthchronology()Copyright © 2014–2018. All rights reserved.