Skip to content Skip to sidebar Skip to footer

How To Add Duration To Localdatetime For Api Level Lower Than 26

I am developing an application for API level 19 (KitKat). I have a LocalDateTime object and a Duration object. I need to add this Duration to LocalDateTime. Android Studio shows th

Solution 1:

Currently you can enable java.time in lower level apis by upgrading grade to 4.0.0. read more here.

Solution 2:

For Android Gradle Plugin 4.0.0+:

Use Java Desugaring feature so you can use Java 8 Date library without any problem for API level lower than 26 too. For more details read this

Old answer:

The bbb answer in the comments is correct.

Currently the best option for android is ThreeTenABP. Jake Wharton explains why it's better to use this library rather than Joda-Time and ThreeTenBP in Android.

Post a Comment for "How To Add Duration To Localdatetime For Api Level Lower Than 26"