
There are already multiple ways to calculate time in Java, so why the need for a Kotlin variant?įrom the proposal itself, The Duration API aims at helping to solve the representation of the interval between two moments in time.

You can directly run the code I present below in the Kotlin playground!Īfter looking at Kover last week, I spent some time diving into one of the other news of the Kotlin 1.6 release : The DurationAPI coming out of Experimental and is available for all flavours of Kotlin (so JS as well 😊)! Let's look quickly together what it has to offer! Why a Duration API? If offers the obvious but also nice extra goodies like coercions and ISO/ String conversions and is notably used to calculate processing time.

TL DR : The DurationAPI is coming out of experimental stage, and offers a nice DSL to easily work with Time durations (duh!).
