Reputation: 6552
I try to get hour from Date data type in Kotlin but get this error:
'getter for hours: Int' is deprecated. Deprecated in Java
And my code:
val date:Date = ...
val hour = date.hours
this is deprecated and getHours()
not found ...
Upvotes: 10
Views: 9761
Reputation: 16087
getHours()
is deprecated. It replaced by Calendar.get(Calendar.HOUR_OF_DAY)
val date:Date = ... // your date
val cal = Calendar.getInstance()
cal.time = date
val hours = cal.get(Calendar.HOUR_OF_DAY)
Upvotes: 19