core / io.islandtime / Date

Date

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) class Date : Comparable<Date>

A date in an ambiguous region.

Constructors

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

<init>

Creates a Date from a year, ISO month number, and day of month.

<init>(year: Int, monthNumber: Int, day: Int)

Creates a Date from a year, month, and day of month.

<init>(year: Int, month: Month, day: Int)

Properties

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dayOfMonth

The day of the month.

val dayOfMonth: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dayOfUnixEpoch

The day of the Unix epoch.

val dayOfUnixEpoch: Long
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dayOfWeek

The day of the week.

val dayOfWeek: DayOfWeek
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

dayOfYear

The day of the year.

val dayOfYear: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

daysSinceUnixEpoch

The number of days away from the Unix epoch (1970-01-01T00:00Z) that this date falls.

val daysSinceUnixEpoch: LongDays
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

isInLeapYear

Check if this date falls within a leap year.

val isInLeapYear: Boolean
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

isLeapDay

Check if this is a leap day.

val isLeapDay: Boolean
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

lengthOfMonth

The length of this date's month in days.

val lengthOfMonth: IntDays
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

lengthOfYear

The length of this date's year in days.

val lengthOfYear: IntDays
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

month

The month of the year.

val month: Month
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

monthNumber

The ISO month number, from 1-12.

val monthNumber: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

unixEpochDay

val unixEpochDay: Long
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

year

The year.

val year: Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

yearMonth

val yearMonth: YearMonth

Functions

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

compareTo

fun compareTo(other: Date): Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

component1

operator fun component1(): Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

component2

operator fun component2(): Month
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

component3

operator fun component3(): Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

copy

Returns a copy of this date with the values of any individual components replaced by the new values specified.

fun copy(year: Int = this.year, month: Month = this.month, dayOfMonth: Int = this.day): Date
fun copy(year: Int = this.year, monthNumber: Int, dayOfMonth: Int = this.day): Date
fun copy(year: Int = this.year, dayOfYear: Int = this.dayOfYear): Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

equals

fun equals(other: Any?): Boolean
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

hashCode

fun hashCode(): Int
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

minus

Returns this date with period subtracted from it.

operator fun minus(period: Period): Dateoperator fun minus(years: IntYears): Date
operator fun minus(years: LongYears): Date
operator fun minus(months: IntMonths): Date
operator fun minus(months: LongMonths): Date
operator fun minus(weeks: IntWeeks): Date
operator fun minus(weeks: LongWeeks): Date
operator fun minus(days: IntDays): Date
operator fun minus(days: LongDays): Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

plus

Returns this date with period added to it.

operator fun plus(period: Period): Dateoperator fun plus(years: IntYears): Date
operator fun plus(years: LongYears): Date
operator fun plus(months: IntMonths): Date
operator fun plus(months: LongMonths): Date
operator fun plus(weeks: IntWeeks): Date
operator fun plus(weeks: LongWeeks): Date
operator fun plus(days: IntDays): Date
operator fun plus(days: LongDays): Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

rangeTo

operator fun rangeTo(other: Date): DateRange

toString

Converts this date to a string in ISO-8601 extended format using the "calendar date" form. For example, 2012-04-15.

(iosArm64, iosX64, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86) fun toString(): <ERROR CLASS>
(jvm) fun toString(): String

Companion Object Properties

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

MAX

The latest supported Date, which can be used as a "far future" sentinel.

val MAX: Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

MIN

The earliest supported Date, which can be used as a "far past" sentinel.

val MIN: Date

Companion Object Functions

(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromDayOfUnixEpoch

Creates a Date from the day of the Unix epoch.

fun fromDayOfUnixEpoch(day: Long): Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromDaysSinceUnixEpoch

Creates a Date from a duration of days relative to the Unix epoch of 1970-01-01.

fun fromDaysSinceUnixEpoch(days: LongDays): Date
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)

fromUnixEpochDay

fun fromUnixEpochDay(day: Long): Date

Extension Functions

(jvm)

endOfWeek

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
(jvm)

startOfWeek

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
(jvm)

toJavaLocalDate

Convert to an equivalent Java LocalDate.

fun Date.toJavaLocalDate(): LocalDate
(jvm)

toWeekDate

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

fun <T> Date.toWeekDate(locale: Locale, action: (year: Int, week: Int, day: Int) -> T): T
(jvm)

week

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.

fun Date.week(locale: Locale): DateRange
(jvm)

weekBasedYear

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.

fun Date.weekBasedYear(locale: Locale): Int
(jvm)

weekOfMonth

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

fun Date.weekOfMonth(locale: Locale): Int
(jvm)

weekOfWeekBasedYear

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

fun Date.weekOfWeekBasedYear(locale: Locale): Int
(jvm)

weekOfYear

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.

fun Date.weekOfYear(locale: Locale): Int
(jvm)

weekRange

fun Date.weekRange(locale: Locale): DateRange

Companion Object Extension Functions

(jvm)

fromWeekDate

Create 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