KotlinLeaner
03/15/2023, 11:26 AMdelay
in my launch function. I always use xxxL
value for delay
. Is there any function to convert seconds
, minutes
& hours
. For example
/ For 30 second
delay(30)
// For 1 minute
delay(1)
// For 2 Hour
delay(2)
It's so much confusing to multiple by value. ThanksMarinJuricev
03/15/2023, 12:03 PMdelay(TimeUnit.SECONDS.toMillis(2))
TimeUnit exposes other enum values, such as:
MINUTES
, HOURS
, DAYS
, etc….gildor
03/15/2023, 12:17 PMKotlinLeaner
03/15/2023, 2:57 PMdelay(Duration(1.minutes))
and imports are
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
but I am gettinggildor
03/15/2023, 4:30 PMKotlinLeaner
03/15/2023, 4:31 PM