YearMonth

class YearMonth(year: Int, month: Month) : Comparable<YearMonth>

A month in a particular year.

Parameters

year

the year

month

the month of the year

Throws

if the year is outside the supported range

Constructors

YearMonth
Link copied to clipboard
common
fun YearMonth(year: Int, monthNumber: Int)

Creates a YearMonth.

YearMonth
Link copied to clipboard
common
fun YearMonth(year: Int, month: Month)

Creates a YearMonth.

Types

Companion
Link copied to clipboard
common
object Companion

Functions

compareTo
Link copied to clipboard
common
open operator override fun compareTo(other: YearMonth): Int
contains
Link copied to clipboard
common
operator fun contains(date: Date): Boolean

Checks if this year contains the specified date.

copy
Link copied to clipboard
common
fun copy(year: Int = this.year, month: Month = this.month): YearMonth
fun copy(year: Int = this.year, monthNumber: Int): YearMonth

Returns a copy of this year-month with the values of any individual components replaced by the new values specified.

equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
minus
Link copied to clipboard
common
operator fun minus(centuries: Centuries): YearMonth

Returns this year-month with centuries subtracted from it.

operator fun minus(decades: Decades): YearMonth

Returns this year-month with decades subtracted from it.

operator fun minus(months: Months): YearMonth

Returns this year-month with months subtracted from it.

operator fun minus(years: Years): YearMonth

Returns this year-month with years subtracted from it.

plus
Link copied to clipboard
common
operator fun plus(centuries: Centuries): YearMonth

Returns this year-month with centuries added to it.

operator fun plus(decades: Decades): YearMonth

Returns this year-month with decades added to it.

operator fun plus(months: Months): YearMonth

Returns this year-month with months added to it.

operator fun plus(years: Years): YearMonth

Returns this year-month with years added to it.

toString
Link copied to clipboard
common
open override fun toString(): String

Converts this date-time to a string in ISO-8601 extended format. For example, 2012-04.

Properties

dateRange
Link copied to clipboard
common
val dateRange: DateRange

The range of dates within this year-month.

dayRange
Link copied to clipboard
common
val dayRange: IntRange

The range of days within this year-month.

endDate
Link copied to clipboard
common
val endDate: Date

The Date representing the last day in this year-month.

firstDayOfYear
Link copied to clipboard
common
val firstDayOfYear: Int

The ordinal date corresponding to the first day of this year-month.

isInLeapYear
Link copied to clipboard
common
val isInLeapYear: Boolean

Checks if this year-month falls within a leap year.

lastDay
Link copied to clipboard
common
val lastDay: Int

The last day of the year-month.

lastDayOfYear
Link copied to clipboard
common
val lastDayOfYear: Int

The ordinal date corresponding to the last day of this year-month.

lengthOfMonth
Link copied to clipboard
common
val lengthOfMonth: Days

The length of the year-month in days.

lengthOfYear
Link copied to clipboard
common
val lengthOfYear: Days

The length of the year in days.

month
Link copied to clipboard
common
val month: Month

The month of the year.

monthNumber
Link copied to clipboard
common
val monthNumber: Int

The ISO month number, from 1-12.

startDate
Link copied to clipboard
common
val startDate: Date

The Date representing the first day in this year-month.

year
Link copied to clipboard
common
val year: Int

The year.

Extensions

atDay
Link copied to clipboard
common
fun YearMonth.atDay(day: Int): Date

Combines a YearMonth with a day of the month to create a Date.

toJavaYearMonth
Link copied to clipboard
fun YearMonth.toJavaYearMonth(): YearMonth

Converts this year-month to an equivalent Java YearMonth.

toNSDateComponents
Link copied to clipboard
darwin
fun YearMonth.toNSDateComponents(includeCalendar: Boolean = false): <ERROR CLASS>

Converts this year-month to an equivalent NSDateComponents object.

toYear
Link copied to clipboard
common
fun YearMonth.toYear(): Year

Returns this year-month with the precision reduced to the year.