Wrangling Dates & Time in Android

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

Part 1: Wrangling Dates & Time in Android

09. Implement the Data-Time API in Android

Episode complete

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 08. Work the Kotlinx-Datetime API

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.

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

Congrats! You’ve finished the course about the Java Date-Time library. But you still miss one piece of the puzzle, implementing it on Android. It might sound very easy to do so, but there’s something you need to know. Java Date-Time library comes out with Java 8. Android, however, natively supports Java 8 only since Android ******SDK 26, also known as Android Oreo. So how can we support version prior to the SDK 26. Well, fortunately, Google has released the Core Library Desugaring, which implements the new language features by performing bytecode transformations called desugar. If you reach minSDK 26 in the future you can simply remove the library desugaring to use the build-in Java 8 APIs.

// Required when setting minSdkVersion to 20 or lower
multiDexEnabled true
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.0'
val currentDate = remember {