viralshah
05/28/2020, 12:41 AMval startTime = Instant.ofEpochMilli(1589778000000).atZone(ZoneOffset.UTC) // May 18 @ 05:00 UTC
val endTime = Instant.ofEpochMilli(1589950800000).atZone(ZoneOffset.UTC) // May 20 @ 05:00 UTC
val res: List<ZonedDateTime> = startTime.hoursUntil(endTime)
//[May 19 05:00, May 19 06:00 ...]
So that I can do a group by day on it
val final = res.groupBy{it.day}.toMap()
{ May 18 -> 19 hours , May 19: 24 hours, May 20: 5 hours}
Is this possible?myaa
05/28/2020, 2:44 AMgenerateSequence
, starting at the current date and incrementing by `step`:
fun ZonedDateTime.until(
end: ZonedDateTime,
step: Duration = Duration.ofHours(1)
) = generateSequence(this) {
(it + step).takeIf { it < end }
}
viralshah
05/28/2020, 2:54 AM