如何为低于26的API级别将Duration添加到LocalDateTime [英] How to add Duration to LocalDateTime for API level lower than 26
问题描述
我正在开发API级别19(KitKat)的应用程序。
I am developing an application for API level 19 (KitKat).
我有一个 LocalDateTime
对象, Duration
对象。我需要将此持续时间
添加到 LocalDateTime
。
I have a LocalDateTime
object and a Duration
object. I need to add this Duration
to LocalDateTime
.
Android Studio显示,由于API级别26是Oreo,并且支持API,因此 LocalDateTime
类的 plus(TemporalAmount)
方法可用现在少于1%的设备。
Android Studio shows that plus(TemporalAmount)
method of LocalDateTime
class is avaliable since API level 26 which is Oreo and it supports less than 1% of devices right now.
如何使用API级别19?
How can I do it with API level 19?
推荐答案
注释中的 bbb 答案是正确的。
The bbb answer in the comments is correct.
当前,Android的最佳选择是 ThreeTenABP 。杰克·沃顿(Jake Wharton)解释了为什么最好使用此库而不是Android中的Joda-Time和ThreeTenBP。
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.
这篇关于如何为低于26的API级别将Duration添加到LocalDateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!