您可以使用该类Calendar:
val currentTime = Calendar.getInstance()
val timeToMatch = Calendar.getInstance()
timeToMatch[Calendar.HOUR_OF_DAY] = hourToMatch
timeToMatch[Calendar.MINUTE] = minuteToMatch
when {
currentTime == timeToMatch -> // the times are equals
currentTime < timeToMatch -> // currentTime is before timeToMatch
currentTime > timeToMatch -> // currentTime is after timeToMatch
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7349 次 |
| 最近记录: |