Some years ago, I worked on one of my first Androi...
# android
Some years ago, I worked on one of my first Android apps, using Kotlin targetting SDK 24. It did a bit with time and at the time
seemed the best approach to get a modernish/capable ability to do lots of things with time (Instant, etc). I'm doing a redone "modern" greenfield version of this app, targetting SDK >= 28. Given that, what the best/idiomatic way of modeling datetimes in an Android app now? Is java.util.Date basically what I want now? or something else?
😶 1
just use Instant
🙏 1
(and sorry "not kotlin")
You could go with Kotlinx.Datetime and keep your options open for moving the code multiplatform in the future.
👍 2
I'd use java8 date time apis. You don't even have to do any sort of desugaring setup if you target something sorta recent (IIRC)
Note that what matters is mim sdk version, not target sdk version. If the min sdk version is < 26, you need to use desugaring.
Also note that kotlinx.datetime uses java.time API under the hood on JVM, so you may still need to enable desugaring depending on min sdk version.