next
Returns a LocalDate that has the given dayOfWeek later than this date.
If the dayOfWeek is already the one this date has, a date one week later will be returned. See nextOrSame for a version that returns the date unchanged if it's already on the given dayOfWeek.
See also
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.random.*
import kotlin.test.*
fun main() {
//sampleStart
val today = LocalDate(2026, 2, 9)
check(today.dayOfWeek == DayOfWeek.MONDAY)
// Find the beginning of the next Monday-based week that doesn't contain the given date.
val startOfNextMondayBasedWeek = today.next(DayOfWeek.MONDAY)
check(startOfNextMondayBasedWeek == LocalDate(2026, 2, 16))
// Find the beginning of the next Sunday-based week that doesn't contain the given date.
val startOfNextSundayBasedWeek = today.next(DayOfWeek.SUNDAY)
check(startOfNextSundayBasedWeek == LocalDate(2026, 2, 15))
//sampleEnd
}Content copied to clipboard