How to get current hour in android?
android
Solution
Instead of using `Time` (because Time class was deprecated in API level 22.) you can use `Calendar` for getting current hour
val rightNow = Calendar.getInstance()
val currentHourIn24Format: Int =rightNow.get(Calendar.HOUR_OF_DAY) // return the hour in 24 hrs format (ranging from 0-23)
val currentHourIn12Format: Int = rightNow.get(Calendar.HOUR) // return the hour in 12 hrs format (ranging from 0-11)
Problem
Time class is no longer possible to use. I want to ask you, how to detect in app 3-4am? I need that to set up for example night mode in my app. Can you give me some example how to do it?