How can you work with dates on Android/Kotlin with minSDK = 21?

问题: I'm trying to find the difference between two dates (in milliseconds) and all the date/time related functions require API 26. private var timerStartTime: LocalDateTime? =...

问题:

I'm trying to find the difference between two dates (in milliseconds) and all the date/time related functions require API 26.

private var timerStartTime: LocalDateTime? = null
val now = now()

[...]

if () {
} else if (now.nano - timerStartTime!!.nano <= 800000000) {
}

回答1:

You can't - those Java 8 APIs aren't available on those lower API levels. There are a couple of backports available, however, for example ThreeTenABP.

  • 发表于 2018-07-06 12:35
  • 阅读 ( 302 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除