Reputation: 151
How do I add n hours to past time in millis? I found another example using days on StackOverflow, but still don't understand how to do it with hours.
Upvotes: 0
Views: 406
Reputation: 9653
val timeWithAddedHours = Calendar.getInstance().apply {
time = Date(timeMillis) //replace timeMillis with past time in millis you want to set like 1604938191509..In case you want to set current time then remove this parameter like Date()
add(Calendar.HOUR_OF_DAY, 1)
}.time
println(timeWithAddedHours)
Upvotes: 2