Wrangling Dates & Time in Android

Dec 15 2022 · Kotlin 1.6.21, Android 13, IntelliJ 2022.1

Part 1: Wrangling Dates & Time in Android

08. Work the Kotlinx-Datetime API

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 07. Format Dates & Time With DataTimeFormatter Next episode: 09. Implement the Data-Time API in Android

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 08. Work the Kotlinx-Datetime API

Check the repository here.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

In the previous video, you learned all the essential concepts about the Java Date-Time library. But since you’re a Kotlin developer you need to know that the JetBrains, Kotlin’s mother, has also released its own Date-Time library written in Kotlin.

val instant = Clock.System.now()
println("instant: $instant")
val tz = TimeZone.of("Europe/Rome")
val local = LocalDate(2022, Month.OCTOBER, 25)
    .atTime(2, 30)
val editedInstant = instant + 5.hours
println("editedInstant: $editedInstant")
val duration: Duration = instant - instant.minus(50, DateTimeUnit.HOUR)
println("duration: $duration")
val convertedIntoPeriod = duration.toDateTimePeriod()
println("days: $convertedIntoPeriod")