Kotlin .todayIn()
Anonymous contributor
Published Nov 29, 2023
Contribute to Docs
The .todayIn() method returns a date when called on a Clock while passing a TimeZone argument.
Syntax
myClock.todayIn(myTimeZone)
myClock: A Clock providing a source for Instants (e.g., 2023-11-21, 00:00:00 UTC+0).Clock.Systemis the clock that refers to the current platform for the current time.myTimeZone: An instance of theTimeZoneclass (e.g., America/Los_Angeles).
Example
The example below demonstrates a basic implementation of .todayIn that returns the current date.
// Import all classes from kotlinx.datetime package.import kotlinx.datetime.*fun main() {val myLocalDate = Clock.System.todayIn(timeZone = TimeZone.currentSystemDefault())println(myLocalDate)}
This example results in an output similar to the following:
2023-11-21
All contributors
- Anonymous contributor
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