YearMonth (Java SE 26 & JDK 26)
- All Implemented Interfaces:
Serializable, Comparable<YearMonth>, Temporal, TemporalAccessor, TemporalAdjuster
-
Method Summary
Adjusts the specified temporal object to have this year-month.
atDay(int dayOfMonth) Combines this year-month with a day-of-month to create a
LocalDate.Returns a
LocalDateat the end of the month.intCompares this year-month to another year-month.
booleanChecks if this year-month is equal to another year-month.
Formats this year-month using the specified formatter.
Obtains an instance of
YearMonthfrom a temporal object.intGets the value of the specified field from this year-month as an
int.longGets the value of the specified field from this year-month as a
long.getMonth()Gets the month-of-year field using the
Monthenum.intGets the month-of-year field from 1 to 12.
intgetYear()inthashCode()A hash code for this year-month.
booleanChecks if this year-month is after the specified year-month.
booleanChecks if this year-month is before the specified year-month.
booleanChecks if the year is a leap year, according to the ISO proleptic calendar system rules.
booleanChecks if the specified field is supported.
booleanChecks if the specified unit is supported.
booleanisValidDay(int dayOfMonth) Checks if the day-of-month is valid for this year-month.
intReturns the length of the month, taking account of the year.
intReturns the length of the year.
Returns a copy of this year-month with the specified amount subtracted.
Returns a copy of this year-month with the specified amount subtracted.
minusMonths(long monthsToSubtract) Returns a copy of this
YearMonthwith the specified number of months subtracted.minusYears(long yearsToSubtract) Returns a copy of this
YearMonthwith the specified number of years subtracted.now()Obtains the current year-month from the system clock in the default time-zone.
Obtains the current year-month from the specified clock.
Obtains the current year-month from the system clock in the specified time-zone.
of(int year, int month) Obtains an instance of
YearMonthfrom a year and month.Obtains an instance of
YearMonthfrom a year and month.Obtains an instance of
YearMonthfrom a text string such as2007-12.Obtains an instance of
YearMonthfrom a text string using a specific formatter.Returns a copy of this year-month with the specified amount added.
Returns a copy of this year-month with the specified amount added.
plusMonths(long monthsToAdd) Returns a copy of this
YearMonthwith the specified number of months added.plusYears(long yearsToAdd) Returns a copy of this
YearMonthwith the specified number of years added.<R> RQueries this year-month using the specified query.
Gets the range of valid values for the specified field.
toString()Outputs this year-month as a
String, such as2007-12.longCalculates the amount of time until another year-month in terms of the specified unit.
Returns an adjusted copy of this year-month.
Returns a copy of this year-month with the specified field set to a new value.
withMonth(int month) Returns a copy of this
YearMonthwith the month-of-year altered.withYear(int year) Returns a copy of this
YearMonthwith the year altered.Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitCreates and returns a copy of this object.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Method Details
-
now
-
now
-
now
-
of
-
of
-
from
-
parse
-
parse
-
isSupported
-
isSupported
-
range
-
get
-
getLong
-
getYear
-
getMonthValue
-
getMonth
-
isLeapYear
-
isValidDay
-
lengthOfMonth
-
lengthOfYear
-
with
-
with
-
withYear
-
withMonth
-
plus
-
plus
-
plusYears
-
plusMonths
-
minus
-
minus
-
minusYears
-
minusMonths
-
query
-
adjustInto
-
until
-
format
-
atDay
-
atEndOfMonth
-
compareTo
-
isAfter
-
isBefore
-
equals
-
hashCode
-
toString
-