DayOfWeek
Published Nov 14, 2023Updated Nov 17, 2023
Contribute to Docs
The DayOfWeek
method is used to return the DayOfWeek
instance for the weekday number, starting with 1
as Monday
.
Syntax
DayOfWeek(isoDayNumber)
isoDayNumber
: An integer value that must correspond to one of the seven days in theDayOfWeek
enumeration class. The numbering follows the ISO-8601 weekday number, whereMonday
is1
andSunday
is7
.- The enumeration class entries have two properties:
Name
, which is represented by astring
, and theOrdinal
, which is represented as an integer.
Example
Here is an example of how to call the DayOfWeek
method:
import kotlinx.datetime.*fun main() {val day = DayOfWeek.of(3)println(day)}
The output will be:
Wednesday
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Kotlin on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Kotlin
Learn Kotlin, the expressive, open-source programming language developed by JetBrains.Beginner Friendly9 hours