https://kotlinlang.org logo
#getting-started
Title
# getting-started
t

TwoClocks

12/04/2021, 8:02 PM
I'm not sure I follow the use case for Kotlin's
Duration
it seems to be missing
.between
? So I need to use Java's, in which case I can't use Kotlin's because importing both doesn't work? What am I missing?
e

ephemient

12/04/2021, 8:15 PM
you can
import x as y
to get around the name conflict locally
t

TwoClocks

12/04/2021, 8:17 PM
oh, and call kotlin's version something else?
or java's, I suppose.
e

ephemient

12/04/2021, 8:20 PM
either or both, right
t

TwoClocks

12/04/2021, 8:40 PM
it doesn't look like Kotlin's Duration will convert to a java Duration.
?
oh, but there is a function to go the other way... ok.
d

Didier Villevalois

12/04/2021, 11:57 PM
@TwoClocks you might want to use kotlinx-datetime. You'll get all you need, including
operator fun Instant.minus(Instant): Duration
to do
thisTime - thatTime
.
t

TwoClocks

12/05/2021, 9:05 PM
@Didier Villevalois thanks! I was not aware of this library. It solves all of my problems.
🎉 1