Package io.islandtime

Date-time primitives and core concepts, including classes such as Date, Time, Instant, and ZonedDateTime.

Types

Date
Link copied to clipboard
common

A date in an ambiguous region.

class Date(year: Int,month: Month,day: Int) : Comparable<Date>
DateTime
Link copied to clipboard
common

A date and time of day in an ambiguous region.

class DateTime(date: Date,time: Time) : Comparable<DateTime>
DateTimeException
Link copied to clipboard
common
open class DateTimeException(message: String?,cause: Throwable?) : Exception
DayOfWeek
Link copied to clipboard
common

A day of the week.

enum DayOfWeek : Enum<DayOfWeek>
Instant
Link copied to clipboard
common

An instant in time with nanosecond-precision.

class Instant : TimePoint<Instant> , Comparable<Instant>
IslandTime
Link copied to clipboard
common

Global configuration for Island Time.

object IslandTime
Month
Link copied to clipboard
common

A month of the year.

enum Month : Enum<Month>
OffsetConversionStrategy
Link copied to clipboard
common

Strategy to use when converting a local date-time accompanied by a UtcOffset to a date and time that are valid according to the rules of a TimeZone.

enum OffsetConversionStrategy : Enum<OffsetConversionStrategy>
OffsetDateTime
Link copied to clipboard
common

A date and time of day with an offset from UTC.

OffsetDateTime is intended to be used primarily for use cases involving persistence or network transfer where the application of time zone rules may be undesirable. For most applications, ZonedDateTime is a better choice since it takes time zone rules into account when performing calendrical calculations.

class OffsetDateTime(dateTime: DateTime,offset: UtcOffset) : TimePoint<OffsetDateTime>
OffsetTime
Link copied to clipboard
common

A time of day with an offset from UTC.

class OffsetTime(time: Time,offset: UtcOffset)
PlatformInstant
Link copied to clipboard

A platform-specific representation of an instant in time.

common
class PlatformInstant
typealias PlatformInstant = <ERROR CLASS>
typealias PlatformInstant = Instant
Time
Link copied to clipboard
common

A time of day in an ambiguous region.

class Time(hour: Int,minute: Int,second: Int,nanosecond: Int) : Comparable<Time>
TimeZone
Link copied to clipboard
common

A time zone.

sealed class TimeZone : Comparable<TimeZone>
UtcOffset
Link copied to clipboard
common

The time shift between a local time and UTC.

To ensure that the offset is within the valid supported range, you must explicitly call validate or validated.

inline class UtcOffset(totalSeconds: IntSeconds) : Comparable<UtcOffset>
Year
Link copied to clipboard
common

A year as defined by ISO-8601.

inline class Year(value: Int) : Comparable<Year>
YearMonth
Link copied to clipboard
common

A month in a particular year.

class YearMonth(year: Int,month: Month) : Comparable<YearMonth>
ZonedDateTime
Link copied to clipboard
common

A date and time of day in a particular region.

ZonedDateTime takes time zone rules into account when performing calendrical calculations.

class ZonedDateTime : TimePoint<ZonedDateTime>

Functions

asTimeZone
Link copied to clipboard
common

Converts this UtcOffset into a fixed-offset TimeZone.

fun UtcOffset.asTimeZone(): TimeZone
asUtcOffset
Link copied to clipboard
common

Converts a duration of hours into a UtcOffset of the same length.

fun IntHours.asUtcOffset(): UtcOffset

Converts a duration of minutes into a UtcOffset of the same length.

fun IntMinutes.asUtcOffset(): UtcOffset

Converts a duration of seconds into a UtcOffset of the same length.

fun IntSeconds.asUtcOffset(): UtcOffset
asZonedDateTime
Link copied to clipboard
common

Converts this OffsetDateTime to an equivalent ZonedDateTime using a fixed-offset time zone.

This comes with the caveat that a fixed-offset zone lacks knowledge of any region and will not respond to daylight savings time changes. To convert to a region-based zone, use toZonedDateTime instead.

fun OffsetDateTime.asZonedDateTime(): ZonedDateTime
at
Link copied to clipboard
common

Combines a year and month to create a YearMonth.

infix fun Year.at(month: Month): YearMonth

Combines a Date with a Time to create a DateTime.

infix fun Date.at(time: Time): DateTime

Combines a local date and time with a UTC offset to create an OffsetDateTime.

infix fun DateTime.at(offset: UtcOffset): OffsetDateTime

Combines a local date with a time and UTC offset to create an OffsetDateTime.

infix fun Date.at(offsetTime: OffsetTime): OffsetDateTime

Combines an instant with a UTC offset to create an OffsetDateTime.

infix fun Instant.at(offset: UtcOffset): OffsetDateTime

Combines an instant with a time zone to create a ZonedDateTime.

infix fun Instant.at(zone: TimeZone): ZonedDateTime

Combines a local date and time with a time zone to create a ZonedDateTime.

Due to daylight savings time transitions, there a few complexities to be aware of. If the local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the earlier offset will be used.

infix fun DateTime.at(zone: TimeZone): ZonedDateTime

Combines a local time with a UTC offset to create an OffsetTime.

infix fun Time.at(offset: UtcOffset): OffsetTime
atDay
Link copied to clipboard
common

Combines a YearMonth with a day of the month to create a Date.

fun YearMonth.atDay(day: Int): Date
atMonth
Link copied to clipboard
common

Combines a year and month number to create a YearMonth.

fun Year.atMonth(number: Int): YearMonth
atTime
Link copied to clipboard
common

Combines a Date with a time to create a DateTime.

fun Date.atTime(hour: Int, minute: Int, second: Int, nanosecond: Int): DateTime
Date
Link copied to clipboard
common

Creates a Date from a year and day of year

fun Date(year: Int, dayOfYear: Int): Date
endOfDayAt
Link copied to clipboard
common

The ZonedDateTime at the last representable instant of the day in zone, taking into account any daylight savings transitions.

fun Date.endOfDayAt(zone: TimeZone): ZonedDateTime
endOfWeek
Link copied to clipboard
common

The date at the end of the week that this date falls in. The first day of the week will be determined by settings. The first day of the week will be determined by the system settings. The first day of the week will be determined by the system settings. This may differ from the first day of the week associated with the default locale on platforms that allow this to be customized.

fun Date.endOfWeek(settings: WeekSettings): Date

The date at the end of the week that this date falls in. The first day of the week will be determined by locale.

fun Date.endOfWeek(locale: Locale): Date

The date-time at the last representable instant of the week that this date-time falls in. The first day of the week will be determined by the system settings. This may differ from the first day of the week associated with the default locale on platforms that allow this to be customized.

fun DateTime.endOfWeek(settings: WeekSettings): DateTime

The date-time at the last representable instant of the week that this date-time falls in. The first day of the week will be determined by locale.

fun DateTime.endOfWeek(locale: Locale): DateTime
fun OffsetDateTime.endOfWeek(locale: Locale): OffsetDateTime
fun ZonedDateTime.endOfWeek(locale: Locale): ZonedDateTime

The date-time at the last representable instant of the week that this date-time falls in. The first day of the week will be determined by the user's system settings. This may differ from the first day of the week associated with the default locale on platforms that allow the user to customize this.

fun OffsetDateTime.endOfWeek(settings: WeekSettings): OffsetDateTime
fun ZonedDateTime.endOfWeek(settings: WeekSettings): ZonedDateTime
fromWeekDate
Link copied to clipboard
common

Creates a Date from an ISO week date.

fun Date.Companion.fromWeekDate(year: Int, week: Int, day: Int): Date

Creates a Date from a week date representation using the week definition in settings.

fun Date.Companion.fromWeekDate(year: Int, week: Int, day: Int, settings: WeekSettings): Date

Creates a Date from a week date representation using the week definition associated with the provided locale.

fun Date.Companion.fromWeekDate(year: Int, week: Int, day: Int, locale: Locale): Date
Instant
Link copied to clipboard
common

Creates the Instant represented by a number of seconds relative to the Unix epoch of 1970-01-01T00:00Z.

fun Instant(secondsSinceUnixEpoch: LongSeconds): Instant

Creates the Instant represented by a number of seconds and additional nanoseconds relative to the Unix epoch of 1970-01-01T00:00Z.

fun Instant(secondsSinceUnixEpoch: LongSeconds, nanosecondAdjustment: IntNanoseconds): Instant
fun Instant(secondsSinceUnixEpoch: LongSeconds, nanosecondAdjustment: LongNanoseconds): Instant

Creates the Instant represented by a number of milliseconds relative to the Unix epoch of 1970-01-01T00:00Z.

fun Instant(millisecondsSinceUnixEpoch: LongMilliseconds): Instant
next
Link copied to clipboard
common

The next date after this one that falls on dayOfWeek.

fun Date.next(dayOfWeek: DayOfWeek): Date

The next date-time after this one that falls on dayOfWeek.

fun DateTime.next(dayOfWeek: DayOfWeek): DateTime
fun OffsetDateTime.next(dayOfWeek: DayOfWeek): OffsetDateTime
fun ZonedDateTime.next(dayOfWeek: DayOfWeek): ZonedDateTime
nextOrSame
Link copied to clipboard
common

The next date that falls on dayOfWeek, or this date if it falls on the same day.

fun Date.nextOrSame(dayOfWeek: DayOfWeek): Date

The next date-time that falls on dayOfWeek, or this date-time if it falls on the same day.

fun DateTime.nextOrSame(dayOfWeek: DayOfWeek): DateTime
fun OffsetDateTime.nextOrSame(dayOfWeek: DayOfWeek): OffsetDateTime
fun ZonedDateTime.nextOrSame(dayOfWeek: DayOfWeek): ZonedDateTime
previous
Link copied to clipboard
common

The last date before this one that falls on dayOfWeek.

fun Date.previous(dayOfWeek: DayOfWeek): Date

The last date-time before this one that falls on dayOfWeek.

fun DateTime.previous(dayOfWeek: DayOfWeek): DateTime
fun OffsetDateTime.previous(dayOfWeek: DayOfWeek): OffsetDateTime
fun ZonedDateTime.previous(dayOfWeek: DayOfWeek): ZonedDateTime
previousOrSame
Link copied to clipboard
common

The previous date that falls on dayOfWeek, or this date if it falls on the same day.

fun Date.previousOrSame(dayOfWeek: DayOfWeek): Date

The previous date-time that falls on dayOfWeek, or this date-time if it falls on the same day.

fun DateTime.previousOrSame(dayOfWeek: DayOfWeek): DateTime
fun OffsetDateTime.previousOrSame(dayOfWeek: DayOfWeek): OffsetDateTime
fun ZonedDateTime.previousOrSame(dayOfWeek: DayOfWeek): ZonedDateTime
roundedDownTo
Link copied to clipboard
common

Returns this time, rounded down to match the precision of a given unit.

This is equivalent to truncatedTo.

fun Time.roundedDownTo(unit: TimeUnit): Time
fun OffsetTime.roundedDownTo(unit: TimeUnit): OffsetTime

Returns this date-time, rounded down to match the precision of a given unit.

This is equivalent to truncatedTo.

fun DateTime.roundedDownTo(unit: TimeUnit): DateTime
fun OffsetDateTime.roundedDownTo(unit: TimeUnit): OffsetDateTime

Returns this date-time, rounded down to match the precision of a given unit.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

This is equivalent to truncatedTo.

fun ZonedDateTime.roundedDownTo(unit: TimeUnit): ZonedDateTime

Returns this instant, rounded down to match the precision of a given unit.

This is equivalent to truncatedTo.

fun Instant.roundedDownTo(unit: TimeUnit): Instant
roundedDownToNearest
Link copied to clipboard
common

Returns this time, rounded down to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

fun Time.roundedDownToNearest(increment: IntHours): Time
fun OffsetTime.roundedDownToNearest(increment: IntHours): OffsetTime

Returns this time, rounded down to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

fun Time.roundedDownToNearest(increment: IntMinutes): Time
fun OffsetTime.roundedDownToNearest(increment: IntMinutes): OffsetTime

Returns this time, rounded down to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

fun Time.roundedDownToNearest(increment: IntSeconds): Time
fun OffsetTime.roundedDownToNearest(increment: IntSeconds): OffsetTime

Returns this time, rounded down to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Time.roundedDownToNearest(increment: IntMilliseconds): Time
fun OffsetTime.roundedDownToNearest(increment: IntMilliseconds): OffsetTime

Returns this time, rounded down to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Time.roundedDownToNearest(increment: IntMicroseconds): Time
fun OffsetTime.roundedDownToNearest(increment: IntMicroseconds): OffsetTime

Returns this time, rounded down to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Time.roundedDownToNearest(increment: IntNanoseconds): Time
fun OffsetTime.roundedDownToNearest(increment: IntNanoseconds): OffsetTime

Returns this date-time, rounded down to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

fun DateTime.roundedDownToNearest(increment: IntHours): DateTime
fun OffsetDateTime.roundedDownToNearest(increment: IntHours): OffsetDateTime

Returns this date-time, rounded down to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

fun DateTime.roundedDownToNearest(increment: IntMinutes): DateTime
fun OffsetDateTime.roundedDownToNearest(increment: IntMinutes): OffsetDateTime

Returns this date-time, rounded down to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

fun DateTime.roundedDownToNearest(increment: IntSeconds): DateTime
fun OffsetDateTime.roundedDownToNearest(increment: IntSeconds): OffsetDateTime

Returns this date-time, rounded down to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

fun DateTime.roundedDownToNearest(increment: IntMilliseconds): DateTime
fun OffsetDateTime.roundedDownToNearest(increment: IntMilliseconds): OffsetDateTime

Returns this date-time, rounded down to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

fun DateTime.roundedDownToNearest(increment: IntMicroseconds): DateTime
fun OffsetDateTime.roundedDownToNearest(increment: IntMicroseconds): OffsetDateTime

Returns this date-time, rounded down to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

fun DateTime.roundedDownToNearest(increment: IntNanoseconds): DateTime
fun OffsetDateTime.roundedDownToNearest(increment: IntNanoseconds): OffsetDateTime

Returns this date-time, rounded down to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedDownToNearest(increment: IntHours): ZonedDateTime

Returns this date-time, rounded down to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedDownToNearest(increment: IntMinutes): ZonedDateTime

Returns this date-time, rounded down to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedDownToNearest(increment: IntSeconds): ZonedDateTime

Returns this date-time, rounded down to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedDownToNearest(increment: IntMilliseconds): ZonedDateTime

Returns this date-time, rounded down to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedDownToNearest(increment: IntMicroseconds): ZonedDateTime

Returns this date-time, rounded down to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedDownToNearest(increment: IntNanoseconds): ZonedDateTime

Returns this instant, rounded down to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

fun Instant.roundedDownToNearest(increment: IntHours): Instant

Returns this instant, rounded down to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

fun Instant.roundedDownToNearest(increment: IntMinutes): Instant

Returns this instant, rounded down to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

fun Instant.roundedDownToNearest(increment: IntSeconds): Instant

Returns this instant, rounded down to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Instant.roundedDownToNearest(increment: IntMilliseconds): Instant

Returns this instant, rounded down to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Instant.roundedDownToNearest(increment: IntMicroseconds): Instant

Returns this instant, rounded down to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Instant.roundedDownToNearest(increment: IntNanoseconds): Instant
roundedTo
Link copied to clipboard
common

Returns this time, rounded to match the precision of a given unit. If the time is halfway between whole values of the unit, it will be rounded up.

fun Time.roundedTo(unit: TimeUnit): Time
fun OffsetTime.roundedTo(unit: TimeUnit): OffsetTime

Returns this date-time, rounded to match the precision of a given unit. If the time is halfway between whole values of the unit, it will be rounded up.

fun DateTime.roundedTo(unit: TimeUnit): DateTime
fun OffsetDateTime.roundedTo(unit: TimeUnit): OffsetDateTime

Returns this date-time, rounded to match the precision of a given unit. If the time is halfway between whole values of the unit, it will be rounded up.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedTo(unit: TimeUnit): ZonedDateTime

Returns this instant, rounded to match the precision of a given unit. If the time is halfway between whole values of the unit, it will be rounded up.

fun Instant.roundedTo(unit: TimeUnit): Instant
roundedToNearest
Link copied to clipboard
common

Returns this time, rounded to the nearest hour that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a 24-hour day.

fun Time.roundedToNearest(increment: IntHours): Time
fun OffsetTime.roundedToNearest(increment: IntHours): OffsetTime

Returns this time, rounded to the nearest minute that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into an hour.

fun Time.roundedToNearest(increment: IntMinutes): Time
fun OffsetTime.roundedToNearest(increment: IntMinutes): OffsetTime

Returns this time, rounded to the nearest second that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a minute.

fun Time.roundedToNearest(increment: IntSeconds): Time
fun OffsetTime.roundedToNearest(increment: IntSeconds): OffsetTime

Returns this time, rounded to the nearest millisecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun Time.roundedToNearest(increment: IntMilliseconds): Time
fun OffsetTime.roundedToNearest(increment: IntMilliseconds): OffsetTime

Returns this time, rounded to the nearest microsecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun Time.roundedToNearest(increment: IntMicroseconds): Time
fun OffsetTime.roundedToNearest(increment: IntMicroseconds): OffsetTime

Returns this time, rounded to the nearest nanosecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun Time.roundedToNearest(increment: IntNanoseconds): Time
fun OffsetTime.roundedToNearest(increment: IntNanoseconds): OffsetTime

Returns this date-time, rounded to the nearest hour that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a 24-hour day.

fun DateTime.roundedToNearest(increment: IntHours): DateTime
fun OffsetDateTime.roundedToNearest(increment: IntHours): OffsetDateTime

Returns this date-time, rounded to the nearest minute that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into an hour.

fun DateTime.roundedToNearest(increment: IntMinutes): DateTime
fun OffsetDateTime.roundedToNearest(increment: IntMinutes): OffsetDateTime

Returns this date-time, rounded to the nearest second that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a minute.

fun DateTime.roundedToNearest(increment: IntSeconds): DateTime
fun OffsetDateTime.roundedToNearest(increment: IntSeconds): OffsetDateTime

Returns this date-time, rounded to the nearest millisecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun DateTime.roundedToNearest(increment: IntMilliseconds): DateTime
fun OffsetDateTime.roundedToNearest(increment: IntMilliseconds): OffsetDateTime

Returns this date-time, rounded to the nearest microsecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun DateTime.roundedToNearest(increment: IntMicroseconds): DateTime
fun OffsetDateTime.roundedToNearest(increment: IntMicroseconds): OffsetDateTime

Returns this date-time, rounded to the nearest nanosecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun DateTime.roundedToNearest(increment: IntNanoseconds): DateTime
fun OffsetDateTime.roundedToNearest(increment: IntNanoseconds): OffsetDateTime

Returns this date-time, rounded to the nearest hour that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a 24-hour day.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedToNearest(increment: IntHours): ZonedDateTime

Returns this date-time, rounded to the nearest minute that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into an hour.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedToNearest(increment: IntMinutes): ZonedDateTime

Returns this date-time, rounded to the nearest second that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a minute.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedToNearest(increment: IntSeconds): ZonedDateTime

Returns this date-time, rounded to the nearest millisecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedToNearest(increment: IntMilliseconds): ZonedDateTime

Returns this date-time, rounded to the nearest microsecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedToNearest(increment: IntMicroseconds): ZonedDateTime

Returns this date-time, rounded to the nearest nanosecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedToNearest(increment: IntNanoseconds): ZonedDateTime

Returns this instant, rounded to the nearest hour that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a 24-hour day.

fun Instant.roundedToNearest(increment: IntHours): Instant

Returns this instant, rounded to the nearest minute that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into an hour.

fun Instant.roundedToNearest(increment: IntMinutes): Instant

Returns this instant, rounded to the nearest second that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a minute.

fun Instant.roundedToNearest(increment: IntSeconds): Instant

Returns this instant, rounded to the nearest millisecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun Instant.roundedToNearest(increment: IntMilliseconds): Instant

Returns this instant, rounded to the nearest microsecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun Instant.roundedToNearest(increment: IntMicroseconds): Instant

Returns this instant, rounded to the nearest nanosecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

The increment must multiply evenly into a second.

fun Instant.roundedToNearest(increment: IntNanoseconds): Instant
roundedUpTo
Link copied to clipboard
common

Returns this time, rounded up to match the precision of a given unit.

fun Time.roundedUpTo(unit: TimeUnit): Time
fun OffsetTime.roundedUpTo(unit: TimeUnit): OffsetTime

Returns this date-time, rounded up to match the precision of a given unit.

The start of the next day will be returned when the resulting time is after midnight.

fun DateTime.roundedUpTo(unit: TimeUnit): DateTime
fun OffsetDateTime.roundedUpTo(unit: TimeUnit): OffsetDateTime

Returns this date-time, rounded up to match the precision of a given unit.

The start of the next day will be returned when the resulting time is after midnight.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedUpTo(unit: TimeUnit): ZonedDateTime

Returns this instant, rounded up to match the precision of a given unit.

fun Instant.roundedUpTo(unit: TimeUnit): Instant
roundedUpToNearest
Link copied to clipboard
common

Returns this time, rounded up to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

fun Time.roundedUpToNearest(increment: IntHours): Time
fun OffsetTime.roundedUpToNearest(increment: IntHours): OffsetTime

Returns this time, rounded up to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

fun Time.roundedUpToNearest(increment: IntMinutes): Time
fun OffsetTime.roundedUpToNearest(increment: IntMinutes): OffsetTime

Returns this time, rounded up to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

fun Time.roundedUpToNearest(increment: IntSeconds): Time
fun OffsetTime.roundedUpToNearest(increment: IntSeconds): OffsetTime

Returns this time, rounded up to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Time.roundedUpToNearest(increment: IntMilliseconds): Time
fun OffsetTime.roundedUpToNearest(increment: IntMilliseconds): OffsetTime

Returns this time, rounded up to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Time.roundedUpToNearest(increment: IntMicroseconds): Time
fun OffsetTime.roundedUpToNearest(increment: IntMicroseconds): OffsetTime

Returns this time, rounded up to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Time.roundedUpToNearest(increment: IntNanoseconds): Time
fun OffsetTime.roundedUpToNearest(increment: IntNanoseconds): OffsetTime

Returns this date-time, rounded up to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

fun DateTime.roundedUpToNearest(increment: IntHours): DateTime
fun OffsetDateTime.roundedUpToNearest(increment: IntHours): OffsetDateTime

Returns this date-time, rounded up to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

fun DateTime.roundedUpToNearest(increment: IntMinutes): DateTime
fun OffsetDateTime.roundedUpToNearest(increment: IntMinutes): OffsetDateTime

Returns this date-time, rounded up to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

fun DateTime.roundedUpToNearest(increment: IntSeconds): DateTime
fun OffsetDateTime.roundedUpToNearest(increment: IntSeconds): OffsetDateTime

Returns this date-time, rounded up to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

fun DateTime.roundedUpToNearest(increment: IntMilliseconds): DateTime
fun OffsetDateTime.roundedUpToNearest(increment: IntMilliseconds): OffsetDateTime

Returns this date-time, rounded up to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

fun DateTime.roundedUpToNearest(increment: IntMicroseconds): DateTime
fun OffsetDateTime.roundedUpToNearest(increment: IntMicroseconds): OffsetDateTime

Returns this date-time, rounded up to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

fun DateTime.roundedUpToNearest(increment: IntNanoseconds): DateTime
fun OffsetDateTime.roundedUpToNearest(increment: IntNanoseconds): OffsetDateTime

Returns this date-time, rounded up to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedUpToNearest(increment: IntHours): ZonedDateTime

Returns this date-time, rounded up to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedUpToNearest(increment: IntMinutes): ZonedDateTime

Returns this date-time, rounded up to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedUpToNearest(increment: IntSeconds): ZonedDateTime

Returns this date-time, rounded up to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedUpToNearest(increment: IntMilliseconds): ZonedDateTime

Returns this date-time, rounded up to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedUpToNearest(increment: IntMicroseconds): ZonedDateTime

Returns this date-time, rounded up to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

fun ZonedDateTime.roundedUpToNearest(increment: IntNanoseconds): ZonedDateTime

Returns this instant, rounded up to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

fun Instant.roundedUpToNearest(increment: IntHours): Instant

Returns this instant, rounded up to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

fun Instant.roundedUpToNearest(increment: IntMinutes): Instant

Returns this instant, rounded up to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

fun Instant.roundedUpToNearest(increment: IntSeconds): Instant

Returns this instant, rounded up to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Instant.roundedUpToNearest(increment: IntMilliseconds): Instant

Returns this instant, rounded up to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Instant.roundedUpToNearest(increment: IntMicroseconds): Instant

Returns this instant, rounded up to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

fun Instant.roundedUpToNearest(increment: IntNanoseconds): Instant
startOfDayAt
Link copied to clipboard
common

The ZonedDateTime at the start of the day in zone, taking into account any daylight savings transitions.

fun Date.startOfDayAt(zone: TimeZone): ZonedDateTime
startOfWeek
Link copied to clipboard
common

The date at the start of the week that this date falls in. The first day of the week will be determined by settings.

fun Date.startOfWeek(settings: WeekSettings): Date

The date at the start of the week that this date falls in. The first day of the week will be determined by locale.

fun Date.startOfWeek(locale: Locale): Date

The date-time at the first instant of the week that this date-time falls in. The first day of the week will be determined by the system settings. This may differ from the first day of the week associated with the default locale on platforms that allow this to be customized.

fun DateTime.startOfWeek(settings: WeekSettings): DateTime

The date-time at the first instant of the week that this date-time falls in. The first day of the week will be determined by locale.

fun DateTime.startOfWeek(locale: Locale): DateTime
fun OffsetDateTime.startOfWeek(locale: Locale): OffsetDateTime
fun ZonedDateTime.startOfWeek(locale: Locale): ZonedDateTime

The date-time at the first instant of the week that this date-time falls in. The first day of the week will be determined by the user's system settings. This may differ from the first day of the week associated with the default locale on platforms that allow the user to customize this.

fun OffsetDateTime.startOfWeek(settings: WeekSettings): OffsetDateTime
fun ZonedDateTime.startOfWeek(settings: WeekSettings): ZonedDateTime
TimeZone
Link copied to clipboard
common

Creates a TimeZone from an identifier.

fun TimeZone(id: String): TimeZone
toDate
Link copied to clipboard
common

Converts a string to a Date.

The string is assumed to be an ISO-8601 calendar date in extended format. For example, 2010-10-05. The output of Date.toString can be safely parsed using this method.

fun String.toDate(): Date

Converts a string to a Date using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Any custom parser must be capable of supplying one of the following field combinations:

fun String.toDate(parser: DateTimeParser, settings: DateTimeParserSettings): Date
toDateAt
Link copied to clipboard
common

Converts this instant to the corresponding Date at offset.

fun Instant.toDateAt(offset: UtcOffset): Date

Converts this instant to the corresponding Date in zone.

fun Instant.toDateAt(zone: TimeZone): Date
toDateTime
Link copied to clipboard
common

Convert a string to a DateTime.

The string is assumed to be an ISO-8601 date-time representation in extended format. For example, 2019-08-22T18:00 or 2019-08-22 18:00:30.123456789. The output of DateTime.toString can be safely parsed using this method.

fun String.toDateTime(): DateTime

Converts a string to a DateTime using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Any custom parser must be capable of supplying the fields necessary to resolve both a Date and Time.

fun String.toDateTime(parser: DateTimeParser, settings: DateTimeParserSettings): DateTime
toDateTimeAt
Link copied to clipboard
common

Converts this instant to the corresponding DateTime at offset.

fun Instant.toDateTimeAt(offset: UtcOffset): DateTime

Converts this instant to the corresponding DateTime in zone.

fun Instant.toDateTimeAt(zone: TimeZone): DateTime
toDayOfWeek
Link copied to clipboard
common

Converts an ISO day of week number to a DayOfWeek.

The ISO week starts on Monday (1) and ends on Sunday (7).

fun Int.toDayOfWeek(): DayOfWeek

Converts a day of week number (1-7) to a DayOfWeek using the week definition provided by settings.

fun Int.toDayOfWeek(settings: WeekSettings): DayOfWeek
toInstant
Link copied to clipboard
common

Converts this date-time to an Instant representing the same time point.

fun OffsetDateTime.toInstant(): Instant
fun ZonedDateTime.toInstant(): Instant

Converts a string to an Instant.

The string is assumed to be an ISO-8601 UTC date-time representation in extended format. For example, 2010-10-05T18:30Z or 2010-10-05T18:30:00.123456789Z. The output of Instant.toString can be safely parsed using this method.

fun String.toInstant(): Instant

Converts a string to an Instant using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings): Instant
toInstantAt
Link copied to clipboard
common

Converts this date-time to the corresponding Instant at offset.

fun DateTime.toInstantAt(offset: UtcOffset): Instant
toMonth
Link copied to clipboard
common

Converts an ISO month number, from 1-12, to a Month.

fun Int.toMonth(): Month
toOffsetDateTime
Link copied to clipboard
common

Returns the combined date, time, and UTC offset.

While similar to ZonedDateTime, an OffsetDateTime representation is unaffected by time zone rule changes or database differences between systems, making it better suited for use cases involving persistence or network transfer.

fun ZonedDateTime.toOffsetDateTime(): OffsetDateTime

Converts a string to an OffsetDateTime.

The string is assumed to be an ISO-8601 date-time with the UTC offset in extended format. For example, 2019-05-30T02:30+01:00. The output of OffsetDateTime.toString can be safely parsed using this method.

fun String.toOffsetDateTime(): OffsetDateTime

Converts a string to an OffsetDateTime using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Any custom parser must be capable of supplying the fields necessary to resolve a Date, Time and UtcOffset.

fun String.toOffsetDateTime(parser: DateTimeParser, settings: DateTimeParserSettings): OffsetDateTime
toOffsetTime
Link copied to clipboard
common

Returns the combined time and UTC offset.

fun OffsetDateTime.toOffsetTime(): OffsetTime
fun ZonedDateTime.toOffsetTime(): OffsetTime

Converts a string to an OffsetTime.

The string is assumed to be an ISO-8601 time with the UTC offset in extended format. For example, 02:30+01:00 or 14:40:23Z. The output of OffsetTime.toString can be safely parsed using this method.

fun String.toOffsetTime(): OffsetTime

Converts a string to an OffsetTime using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Any custom parser must be capable of supplying the fields necessary to resolve both a Time and UtcOffset.

fun String.toOffsetTime(parser: DateTimeParser, settings: DateTimeParserSettings): OffsetTime
toTime
Link copied to clipboard
common

Converts a string to a Time.

The string is assumed to be an ISO-8601 time representation in extended format. For example, 05, 05:30, 05:30:00, or 05:30:00.123456789. The output of Time.toString can be safely parsed using this method.

fun String.toTime(): Time

Converts a string to a Time using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

fun String.toTime(parser: DateTimeParser, settings: DateTimeParserSettings): Time
toUtcOffset
Link copied to clipboard
common

Converts a string to a UtcOffset.

The string is assumed to be an ISO-8601 UTC offset representation in extended format. For example, Z, +05, or -04:30. The output of UtcOffset.toString can be safely parsed using this method.

fun String.toUtcOffset(): UtcOffset

Converts a string to a UtcOffset using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

fun String.toUtcOffset(parser: DateTimeParser, settings: DateTimeParserSettings): UtcOffset
toWeekDate
Link copied to clipboard
common

Converts this date to an ISO week date representation.

inline fun <T> Date.toWeekDate(action: (Int, Int, Int) -> T): T

Converts this date to a week date representation using the week definition in settings.

inline fun <T> Date.toWeekDate(settings: WeekSettings, action: (Int, Int, Int) -> T): T

Converts this date to a week date representation using the week definition associated with the provided locale.

Keep in mind that that the system's calendar settings may differ from that of the default locale on some platforms. To respect the system calendar settings, use WeekSettings.systemDefault instead.

inline fun <T> Date.toWeekDate(locale: Locale, action: (Int, Int, Int) -> T): T
toYear
Link copied to clipboard
common

Returns this year-month with the precision reduced to the year.

fun YearMonth.toYear(): Year

Returns this date with the precision reduced to the year.

fun Date.toYear(): Year

Returns this date-time with the precision reduced to the year.

fun DateTime.toYear(): Year
fun OffsetDateTime.toYear(): Year
fun ZonedDateTime.toYear(): Year

Converts a string to a Year.

The string is assumed to be an ISO-8601 year. For example, 2010, +002010, or Y12345. The output of Year.toString can be safely parsed using this method.

fun String.toYear(): Year

Converts a string to a Year using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

The parser must be capable of supplying DateTimeField.YEAR.

fun String.toYear(parser: DateTimeParser, settings: DateTimeParserSettings): Year
toYearMonth
Link copied to clipboard
common

Returns this date with the precision reduced to the month.

fun Date.toYearMonth(): YearMonth

Returns this date-time with the precision reduced to the month.

fun DateTime.toYearMonth(): YearMonth
fun OffsetDateTime.toYearMonth(): YearMonth
fun ZonedDateTime.toYearMonth(): YearMonth

Converts a string to a YearMonth.

The string is assumed to be an ISO-8601 year-month. For example, 2010-05 or 1960-12. The output of YearMonth.toString can be safely parsed using this method.

fun String.toYearMonth(): YearMonth

Converts a string to a YearMonth using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

The parser must be capable of supplying DateTimeField.YEAR and DateTimeField.MONTH_OF_YEAR.

fun String.toYearMonth(parser: DateTimeParser, settings: DateTimeParserSettings): YearMonth
toZonedDateTime
Link copied to clipboard
common

Converts this OffsetDateTime to a ZonedDateTime using the specified strategy to adjust it to a valid date, time, and offset in zone.

Alternatively, you can use asZonedDateTime to convert to a ZonedDateTime with an equivalent fixed-offset zone. However, this comes with the caveat that a fixed-offset zone lacks knowledge of any region and will not respond to daylight savings time changes.

fun OffsetDateTime.toZonedDateTime(zone: TimeZone, strategy: OffsetConversionStrategy): ZonedDateTime

Converts a string to a ZonedDateTime.

The string is assumed to be a complete ISO-8601 date and time representation in extended format, optionally including a non-standard region ID. For example, 2005-05-06T23:30+01 or 2005-05-06T23:30-04:00[America/New_York].

The output of ZonedDateTime.toString can be safely parsed using this method.

fun String.toZonedDateTime(): ZonedDateTime

Converts a string to a ZonedDateTime using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

fun String.toZonedDateTime(parser: DateTimeParser, settings: DateTimeParserSettings): ZonedDateTime
truncatedTo
Link copied to clipboard
common

Returns this time, rounded down to match the precision of a given unit.

This is equivalent to roundedDownTo.

fun Time.truncatedTo(unit: TimeUnit): Time
fun OffsetTime.truncatedTo(unit: TimeUnit): OffsetTime

Returns this date-time, rounded down to match the precision of a given unit.

This is equivalent to roundedDownTo.

fun DateTime.truncatedTo(unit: TimeUnit): DateTime
fun OffsetDateTime.truncatedTo(unit: TimeUnit): OffsetDateTime
fun ZonedDateTime.truncatedTo(unit: TimeUnit): ZonedDateTime

Returns this instant, rounded down to match the precision of a given unit.

This is equivalent to roundedDownTo.

fun Instant.truncatedTo(unit: TimeUnit): Instant
UtcOffset
Link copied to clipboard
common

Creates a UTC offset of hours, minutes, and seconds. Each component must be within its valid range and without any mixed positive and negative values.

fun UtcOffset(hours: IntHours, minutes: IntMinutes, seconds: IntSeconds): UtcOffset
week
Link copied to clipboard
common

The range defining the week that this date falls within. The first day of the week will be determined by the provided settings.

fun Date.week(settings: WeekSettings): DateRange

The range defining the week that this date falls within. The first day of the week will be the default associated with the provided locale.

Keep in mind that that the system's calendar settings may differ from that of the default locale on some platforms. To respect the system calendar settings, use WeekSettings.systemDefault instead.

fun Date.week(locale: Locale): DateRange

The interval defining the week that this date-time falls within. The first day of the week will be determined by the provided settings.

fun DateTime.week(settings: WeekSettings): DateTimeInterval
fun OffsetDateTime.week(settings: WeekSettings): OffsetDateTimeInterval
fun ZonedDateTime.week(settings: WeekSettings): ZonedDateTimeInterval

The interval defining the week that this date-time falls within. The first day of the week will be the default associated with the provided locale.

Keep in mind that that the system's calendar settings may differ from that of the default locale on some platforms. To respect the system calendar settings, use WeekSettings.systemDefault instead.

fun DateTime.week(locale: Locale): DateTimeInterval
fun OffsetDateTime.week(locale: Locale): OffsetDateTimeInterval
fun ZonedDateTime.week(locale: Locale): ZonedDateTimeInterval
weekBasedYear
Link copied to clipboard
common

The week-based year, calculated using the week definition in settings. This value differs from the regular ISO year when the week number falls in the preceding or following year.

fun Date.weekBasedYear(settings: WeekSettings): Int
fun DateTime.weekBasedYear(settings: WeekSettings): Int
fun OffsetDateTime.weekBasedYear(settings: WeekSettings): Int
fun ZonedDateTime.weekBasedYear(settings: WeekSettings): Int

The week-based year, calculated using the week definition associated with the provided locale. This value differs from the regular ISO year when the week number falls in the preceding or following year.

Keep in mind that that the system's calendar settings may differ from that of the default locale on some platforms. To respect the system calendar settings, use WeekSettings.systemDefault instead.

fun Date.weekBasedYear(locale: Locale): Int
fun DateTime.weekBasedYear(locale: Locale): Int
fun OffsetDateTime.weekBasedYear(locale: Locale): Int
fun ZonedDateTime.weekBasedYear(locale: Locale): Int
weekOfMonth
Link copied to clipboard
common

The week of the month, from 0-6, calculated using the week definition in settings.

fun Date.weekOfMonth(settings: WeekSettings): Int
fun DateTime.weekOfMonth(settings: WeekSettings): Int
fun OffsetDateTime.weekOfMonth(settings: WeekSettings): Int
fun ZonedDateTime.weekOfMonth(settings: WeekSettings): Int

The week of the month, from 0-6, calculated using the default week definition associated with the provided locale.

Keep in mind that that the system's calendar settings may differ from that of the default locale on some platforms. To respect the system calendar settings, use WeekSettings.systemDefault instead.

fun Date.weekOfMonth(locale: Locale): Int
fun DateTime.weekOfMonth(locale: Locale): Int
fun OffsetDateTime.weekOfMonth(locale: Locale): Int
fun ZonedDateTime.weekOfMonth(locale: Locale): Int
weekOfWeekBasedYear
Link copied to clipboard
common

The week number of the week-based year, calculated using the week definition in settings.

fun Date.weekOfWeekBasedYear(settings: WeekSettings): Int
fun DateTime.weekOfWeekBasedYear(settings: WeekSettings): Int
fun OffsetDateTime.weekOfWeekBasedYear(settings: WeekSettings): Int
fun ZonedDateTime.weekOfWeekBasedYear(settings: WeekSettings): Int

The week number of the week-based year, calculated using the week definition associated with the provided locale.

Keep in mind that that the system's calendar settings may differ from that of the default locale on some platforms. To respect the system calendar settings, use WeekSettings.systemDefault instead.

fun Date.weekOfWeekBasedYear(locale: Locale): Int
fun DateTime.weekOfWeekBasedYear(locale: Locale): Int
fun OffsetDateTime.weekOfWeekBasedYear(locale: Locale): Int
fun ZonedDateTime.weekOfWeekBasedYear(locale: Locale): Int
weekOfYear
Link copied to clipboard
common

The week of the year, calculated using the week definition in settings. If the week number is associated with the preceding year, 0 will be returned.

To obtain the week number of the week-based year, use weekOfWeekBasedYear instead.

fun Date.weekOfYear(settings: WeekSettings): Int
fun DateTime.weekOfYear(settings: WeekSettings): Int
fun OffsetDateTime.weekOfYear(settings: WeekSettings): Int
fun ZonedDateTime.weekOfYear(settings: WeekSettings): Int

The week of the year, calculated using the week definition associated with the provided locale. If the week number is associated with the preceding year, 0 will be returned.

To obtain the week number of the week-based year, use weekOfWeekBasedYear instead.

Keep in mind that that the system's calendar settings may differ from that of the default locale on some platforms. To respect the system calendar settings, use WeekSettings.systemDefault instead.

fun Date.weekOfYear(locale: Locale): Int
fun DateTime.weekOfYear(locale: Locale): Int
fun OffsetDateTime.weekOfYear(locale: Locale): Int
fun ZonedDateTime.weekOfYear(locale: Locale): Int
ZonedDateTime
Link copied to clipboard
common

Creates a ZonedDateTime from a local date and time.

Due to daylight savings time transitions, there a few complexities to be aware of. If the local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the earlier offset will be used.

fun ZonedDateTime(year: Int, month: Month, day: Int, hour: Int, minute: Int, second: Int, nanosecond: Int, zone: TimeZone): ZonedDateTime
fun ZonedDateTime(year: Int, monthNumber: Int, day: Int, hour: Int, minute: Int, second: Int, nanosecond: Int, zone: TimeZone): ZonedDateTime
fun ZonedDateTime(year: Int, dayOfYear: Int, hour: Int, minute: Int, second: Int, nanosecond: Int, zone: TimeZone): ZonedDateTime
fun ZonedDateTime(date: Date, time: Time, zone: TimeZone): ZonedDateTime
fun ZonedDateTime(dateTime: DateTime, zone: TimeZone): ZonedDateTime

Properties

endOfDay
Link copied to clipboard
common

The DateTime at the last representable instant of the day. Daylight savings transitions are not taken into account, so the returned date-time may not necessarily exist in all time zones.

val Date.endOfDay: DateTime
endOfMonth
Link copied to clipboard
common

The date at the end of the month that this date falls in.

val Date.endOfMonth: Date
endOfMonth
Link copied to clipboard
common

The date-time at the last representable instant of the month that this date-time falls in.

val DateTime.endOfMonth: DateTime
endOfMonth
Link copied to clipboard
common

The date-time at the last representable instant of the month that this date-time falls in.

val OffsetDateTime.endOfMonth: OffsetDateTime
endOfMonth
Link copied to clipboard
common

The date-time at the last representable instant of the month that this date-time falls in.

val ZonedDateTime.endOfMonth: ZonedDateTime
endOfWeek
Link copied to clipboard
common

The date at the end of the ISO week that this date falls in.

The ISO week starts on Monday and ends on Sunday.

val Date.endOfWeek: Date
endOfWeek
Link copied to clipboard
common

The date-time at the last representable instant of the ISO week that this date-time falls in.

The ISO week starts on Monday and ends on Sunday.

val DateTime.endOfWeek: DateTime
endOfWeek
Link copied to clipboard
common

The date-time at the last representable instant of the ISO week that this date-time falls in.

The ISO week starts on Monday and ends on Sunday.

val OffsetDateTime.endOfWeek: OffsetDateTime
endOfWeek
Link copied to clipboard
common

The date-time at the last representable instant of the ISO week that this date-time falls in.

The ISO week starts on Monday and ends on Sunday.

val ZonedDateTime.endOfWeek: ZonedDateTime
endOfYear
Link copied to clipboard
common

The date at the end of the year that this date falls in.

val Date.endOfYear: Date
endOfYear
Link copied to clipboard
common

The date-time at the last representable instant of the year that this date-time falls in.

val DateTime.endOfYear: DateTime
endOfYear
Link copied to clipboard
common

The date-time at the last representable instant of the year that this date-time falls in.

val OffsetDateTime.endOfYear: OffsetDateTime
endOfYear
Link copied to clipboard
common

The date-time at the last representable instant of the year that this date-time falls in.

val ZonedDateTime.endOfYear: ZonedDateTime
isInLeapDay
Link copied to clipboard
common

Checks if this date-time falls within February 29.

val DateTime.isInLeapDay: Boolean
isInLeapDay
Link copied to clipboard
common

Checks if this date-time falls within February 29.

val OffsetDateTime.isInLeapDay: Boolean
isInLeapDay
Link copied to clipboard
common

Checks if this date-time falls within February 29.

val ZonedDateTime.isInLeapDay: Boolean
isInLeapYear
Link copied to clipboard
common

Checks if this date falls within a leap year.

val Date.isInLeapYear: Boolean
isInLeapYear
Link copied to clipboard
common

Checks if this date-time falls within a leap year.

val DateTime.isInLeapYear: Boolean
isInLeapYear
Link copied to clipboard
common

Checks if this date-time falls within a leap year.

val OffsetDateTime.isInLeapYear: Boolean
isInLeapYear
Link copied to clipboard
common

Checks if this date-time falls within a leap year.

val ZonedDateTime.isInLeapYear: Boolean
isLeapDay
Link copied to clipboard
common

Checks if this date is February 29.

val Date.isLeapDay: Boolean
lengthOfMonth
Link copied to clipboard
common

The length of this date's month in days.

val Date.lengthOfMonth: IntDays
lengthOfMonth
Link copied to clipboard
common

The length of this date-time's month in days.

val DateTime.lengthOfMonth: IntDays
lengthOfMonth
Link copied to clipboard
common

The length of this date-time's month in days.

val OffsetDateTime.lengthOfMonth: IntDays
lengthOfMonth
Link copied to clipboard
common

The length of this date-time's month in days.

val ZonedDateTime.lengthOfMonth: IntDays
lengthOfWeekBasedYear
Link copied to clipboard
common

The length of the ISO week-based year that this date falls in, either 52 or 53 weeks.

val Date.lengthOfWeekBasedYear: IntWeeks
lengthOfWeekBasedYear
Link copied to clipboard
common

The length of the ISO week-based year that this date-time falls in, either 52 or 53 weeks.

val DateTime.lengthOfWeekBasedYear: IntWeeks
lengthOfWeekBasedYear
Link copied to clipboard
common

The length of the ISO week-based year that this date-time falls in, either 52 or 53 weeks.

val OffsetDateTime.lengthOfWeekBasedYear: IntWeeks
lengthOfWeekBasedYear
Link copied to clipboard
common

The length of the ISO week-based year that this date-time falls in, either 52 or 53 weeks.

val ZonedDateTime.lengthOfWeekBasedYear: IntWeeks
lengthOfYear
Link copied to clipboard
common

The length of this date's year in days.

val Date.lengthOfYear: IntDays
lengthOfYear
Link copied to clipboard
common

The length of this date-time's year in days.

val DateTime.lengthOfYear: IntDays
lengthOfYear
Link copied to clipboard
common

The length of this date-time's year in days.

val OffsetDateTime.lengthOfYear: IntDays
lengthOfYear
Link copied to clipboard
common

The length of this date-time's year in days.

val ZonedDateTime.lengthOfYear: IntDays
startOfDay
Link copied to clipboard
common

The DateTime at the start of the day. Daylight savings transitions are not taken into account, so the returned date-time may not necessarily exist in all time zones.

val Date.startOfDay: DateTime
startOfMonth
Link copied to clipboard
common

The date at the start of the month that this date falls in.

val Date.startOfMonth: Date
startOfMonth
Link copied to clipboard
common

The date-time at the first instant of the month that this date-time falls in.

val DateTime.startOfMonth: DateTime
startOfMonth
Link copied to clipboard
common

The date-time at the first instant of the month that this date-time falls in.

val OffsetDateTime.startOfMonth: OffsetDateTime
startOfMonth
Link copied to clipboard
common

The date-time at the first instant of the month that this date-time falls in.

val ZonedDateTime.startOfMonth: ZonedDateTime
startOfWeek
Link copied to clipboard
common

The date at the start of the ISO week that this date falls in.

The ISO week starts on Monday and ends on Sunday.

val Date.startOfWeek: Date
startOfWeek
Link copied to clipboard
common

The date-time at the first instant of the ISO week that this date-time falls in.

The ISO week starts on Monday and ends on Sunday.

val DateTime.startOfWeek: DateTime
startOfWeek
Link copied to clipboard
common

The date-time at the first instant of the ISO week that this date-time falls in.

The ISO week starts on Monday and ends on Sunday.

val OffsetDateTime.startOfWeek: OffsetDateTime
startOfWeek
Link copied to clipboard
common

The date-time at the first instant of the ISO week that this date-time falls in.

The ISO week starts on Monday and ends on Sunday.

val ZonedDateTime.startOfWeek: ZonedDateTime
startOfYear
Link copied to clipboard
common

The date at the start of the year that this date falls in.

val Date.startOfYear: Date
startOfYear
Link copied to clipboard
common

The date-time at the first instant of the year that this date-time falls in.

val DateTime.startOfYear: DateTime
startOfYear
Link copied to clipboard
common

The date-time at the first instant of the year that this date-time falls in.

val OffsetDateTime.startOfYear: OffsetDateTime
startOfYear
Link copied to clipboard
common

The date-time at the first instant of the year that this date-time falls in.

val ZonedDateTime.startOfYear: ZonedDateTime
week
Link copied to clipboard
common

The range defining the ISO week that this date falls within.

The ISO week starts on Monday and ends on Sunday.

val Date.week: DateRange
week
Link copied to clipboard
common

The interval defining the ISO week that this date-time falls within.

The ISO week starts on Monday and ends on Sunday.

val DateTime.week: DateTimeInterval
week
Link copied to clipboard
common

The interval defining the ISO week that this date-time falls within.

The ISO week starts on Monday and ends on Sunday.

val OffsetDateTime.week: OffsetDateTimeInterval
week
Link copied to clipboard
common

The interval defining the ISO week that this date-time falls within.

The ISO week starts on Monday and ends on Sunday.

val ZonedDateTime.week: ZonedDateTimeInterval
weekBasedYear
Link copied to clipboard
common

The week-based year used in the ISO week date system. This value differs from the regular ISO year when the week number falls in the preceding or following year.

val Date.weekBasedYear: Int
weekBasedYear
Link copied to clipboard
common

The week-based year used in the ISO week date system. This value differs from the regular ISO year when the week number falls in the preceding or following year.

val DateTime.weekBasedYear: Int
weekBasedYear
Link copied to clipboard
common

The week-based year used in the ISO week date system. This value differs from the regular ISO year when the week number falls in the preceding or following year.

val OffsetDateTime.weekBasedYear: Int
weekBasedYear
Link copied to clipboard
common

The week-based year used in the ISO week date system. This value differs from the regular ISO year when the week number falls in the preceding or following year.

val ZonedDateTime.weekBasedYear: Int
weekOfMonth
Link copied to clipboard
common

The week of the month, from 0-6, calculated using the ISO week definition.

val Date.weekOfMonth: Int
weekOfMonth
Link copied to clipboard
common

The week of the month, from 0-6, calculated using the ISO week definition.

val DateTime.weekOfMonth: Int
weekOfMonth
Link copied to clipboard
common

The week of the month, from 0-6, calculated using the ISO week definition.

val OffsetDateTime.weekOfMonth: Int
weekOfMonth
Link copied to clipboard
common

The week of the month, from 0-6, calculated using the ISO week definition.

val ZonedDateTime.weekOfMonth: Int
weekOfWeekBasedYear
Link copied to clipboard
common

The week number used in the ISO week date system.

val Date.weekOfWeekBasedYear: Int
weekOfWeekBasedYear
Link copied to clipboard
common

The week number used in the ISO week date system.

val DateTime.weekOfWeekBasedYear: Int
weekOfWeekBasedYear
Link copied to clipboard
common

The week number used in the ISO week date system.

val OffsetDateTime.weekOfWeekBasedYear: Int
weekOfWeekBasedYear
Link copied to clipboard
common

The week number used in the ISO week date system.

val ZonedDateTime.weekOfWeekBasedYear: Int
weekOfYear
Link copied to clipboard
common

The week of the year, calculated using the ISO week definition. If the week number is associated with the preceding year, 0 will be returned.

To obtain the week number used in the ISO week date system, use weekOfWeekBasedYear instead.

val Date.weekOfYear: Int
weekOfYear
Link copied to clipboard
common

The week of the year, calculated using the ISO week definition. If the week number is associated with the preceding year, 0 will be returned.

To obtain the week number used in the ISO week date system, use weekOfWeekBasedYear instead.

val DateTime.weekOfYear: Int
weekOfYear
Link copied to clipboard
common

The week of the year, calculated using the ISO week definition. If the week number is associated with the preceding year, 0 will be returned.

To obtain the week number used in the ISO week date system, use weekOfWeekBasedYear instead.

val OffsetDateTime.weekOfYear: Int
weekOfYear
Link copied to clipboard
common

The week of the year, calculated using the ISO week definition. If the week number is associated with the preceding year, 0 will be returned.

To obtain the week number used in the ISO week date system, use weekOfWeekBasedYear instead.

val ZonedDateTime.weekOfYear: Int