Month
The enumeration class representing the 12 months of the year.
Can be acquired from LocalDate.month or constructed using the Month
factory function that accepts the month number. This number can be obtained from the number property.
Samples
import kotlinx.datetime.*
import kotlin.test.*
fun main() {
//sampleStart
// Providing different behavior based on what month it is today
val today = Clock.System.todayIn(TimeZone.currentSystemDefault())
when (today.month) {
Month.JANUARY -> check(today.month.number == 1)
Month.FEBRUARY -> check(today.month.number == 2)
Month.MARCH -> check(today.month.number == 3)
Month.APRIL -> check(today.month.number == 4)
Month.MAY -> check(today.month.number == 5)
Month.JUNE -> check(today.month.number == 6)
Month.JULY -> check(today.month.number == 7)
Month.AUGUST -> check(today.month.number == 8)
Month.SEPTEMBER -> check(today.month.number == 9)
Month.OCTOBER -> check(today.month.number == 10)
Month.NOVEMBER -> check(today.month.number == 11)
Month.DECEMBER -> check(today.month.number == 12)
else -> TODO("A new month was added to the calendar?")
}
//sampleEnd
}
Properties
Returns a representation of an immutable list of all enum entries, in the order they're declared.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
Returns a representation of an immutable list of all enum entries, in the order they're declared.
Functions
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns an array containing the constants of this enum type, in the order they're declared.