Month

actual enum Month : Enum<Month> (source)
expect enum Month : Enum<Month> (source)

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
}
actual typealias Month = java.time.Month(source)
actual enum Month : Enum<Month> (source)

Entries

Link copied to clipboard

January, month #01, with 31 days.

Link copied to clipboard

February, month #02, with 28 days, or 29 in leap years.

Link copied to clipboard

March, month #03, with 31 days.

Link copied to clipboard

April, month #04, with 30 days.

Link copied to clipboard

May, month #05, with 31 days.

Link copied to clipboard

June, month #06, with 30 days.

Link copied to clipboard

July, month #07, with 31 days.

Link copied to clipboard

August, month #08, with 31 days.

Link copied to clipboard

September, month #09, with 30 days.

Link copied to clipboard

October, month #10, with 31 days.

Link copied to clipboard

November, month #11, with 30 days.

Link copied to clipboard

December, month #12, with 31 days.

Properties

entries
Link copied to clipboard

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.

Link copied to clipboard

The number of the Month. January is 1, December is 12.

Functions

valueOf
Link copied to clipboard
fun valueOf(value: String): Month

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.)

fun valueOf(value: String): Month

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.)

fun valueOf(value: String): Month

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.)

values
Link copied to clipboard

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.

Returns an array containing the constants of this enum type, in the order they're declared.