Some years ago, I worked on one of my first Androi...
# android
t
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
com.jakewharton.threetenabp
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
i
just use Instant
🙏 1
t
(and sorry "not kotlin")
p
You could go with Kotlinx.Datetime and keep your options open for moving the code multiplatform in the future.
👍 2
c
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)
a
Note that what matters is mim sdk version, not target sdk version. If the min sdk version is < 26, you need to use desugaring.
1
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.