year

actual val year: Int(source)
expect val year: Int(source)

Returns the year component of the year-month.

Samples

import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlinx.datetime.onDay
import kotlin.test.*

fun main() { 
   //sampleStart 
   // Getting the year
check(YearMonth(2024, Month.APRIL).year == 2024)
check(YearMonth(0, Month.APRIL).year == 0)
check(YearMonth(-2024, Month.APRIL).year == -2024) 
   //sampleEnd
}
actual val year: Int(source)