Kotlin 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 theDayOfWeekenumeration class. The numbering follows the ISO-8601 weekday number, whereMondayis1andSundayis7.- 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
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn Kotlin, the expressive, open-source programming language developed by JetBrains.
- Beginner Friendly.9 hours