class YearMonth
source · line 8public class YearMonth public constructor(
/**
* The proleptic Gregorian year, including year zero.
*/
public val year: Int,
/**
* The one-based month number in 1..12.
*/
public val monthNumber: Int) : Equals<YearMonth>, Compare<YearMonth>, Hash, ToString
- Supertype
Equals<YearMonth> - Supertype
Compare<YearMonth> - Supertype
Hash - Supertype
ToString
An immutable Gregorian year and month in the same supported year range as LocalDate.
function equals
source · line 55public override operator fun equals(other: YearMonth): Boolean
- Overrides
equals
Compares the stored value components for equality.
parameter other
source · line 55other: YearMonth
function plusMonths
source · line 41public fun plusMonths(value: Long): YearMonth
Shifts by signed calendar months, rejecting unsupported years.
parameter value
source · line 41value: Long
property lengthOfMonth
source · line 29public val lengthOfMonth: Int
get: public read-only
The number of days in this month, including leap-year rules.
getter get
source · line 29get(): Int
function compareTo
source · line 59public override operator fun compareTo(other: YearMonth): Long
- Overrides
compareTo
Orders values by their chronological or numeric value; only the result sign is significant.
parameter other
source · line 59other: YearMonth
function toString
source · line 68public override fun toString(): String
- Overrides
toString
Formats this value as ISO year-month.
property year
source · line 12public val year: Int
get: public read-only
The proleptic Gregorian year, including year zero.
constructor constructor
source · line 8constructor(public val year: Int, public val monthNumber: Int)
parameter year
source · line 12public val year: Int
parameter monthNumber
source · line 16public val monthNumber: Int
function plusYears
source · line 48public fun plusYears(value: Long): YearMonth
Shifts by signed calendar years, retaining the month and rejecting unsupported years.
parameter value
source · line 48value: Long
property month
source · line 25public val month: Month
get: public read-only
The corresponding Gregorian Month value.
getter get
source · line 25get(): Month
function hash
source · line 64public override fun hash(): Long
- Overrides
hash
Computes a hash consistent with component equality.
property isLeapYear
source · line 33public val isLeapYear: Boolean
get: public read-only
Whether the year is leap under proleptic Gregorian rules.
getter get
source · line 33get(): Boolean
property monthNumber
source · line 16public val monthNumber: Int
get: public read-only
The one-based month number in 1..12.
constructor constructor
source · line 21constructor(year: Int, month: Month)
parameter year
source · line 21year: Int
parameter month
source · line 21month: Month
function atDay
source · line 37public fun atDay(dayOfMonth: Int): LocalDate
Constructs a date in this month, rejecting an invalid day number.
parameter dayOfMonth
source · line 37dayOfMonth: Int