plus

operator fun plus(duration: Duration): Instant(source)

Returns an instant that is the result of adding the specified duration to this instant.

If the duration is positive, the returned instant is later than this instant. If the duration is negative, the returned instant is earlier than this instant.

The return value is clamped to the boundaries of Instant if the result exceeds them.

Pitfall: Duration.Companion.days are multiples of 24 hours, but in some time zones, some days can be shorter or longer because clocks are shifted. Consider using kotlinx-datetime for arithmetic operations that take time zone transitions into account.

Since Kotlin

2.1

Samples

import kotlin.test.*
import kotlin.time.*
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.nanoseconds

fun main() { 
   //sampleStart 
   // Finding a moment that's later than the starting point by the given amount of real time
val instant = Instant.fromEpochSeconds(7 * 60 * 60, nanosecondAdjustment = 123_456_789)
val fiveHoursLater = instant + 5.hours
println(fiveHoursLater.epochSeconds == 12 * 60 * 60L) // true
println(fiveHoursLater.nanosecondsOfSecond == 123_456_789) // true 
   //sampleEnd
}