Date

A date in an ambiguous region.

class Date(year: Int,month: Month,day: Int) : Comparable<Date>

Parameters

day

the day of the month

month

the month

year

the year

Constructors

Date
Link copied to clipboard
common

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

fun Date(year: Int, monthNumber: Int, day: Int)
Date
Link copied to clipboard
common

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

fun Date(year: Int, month: Month, day: Int)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

compareTo
Link copied to clipboard
common
open operator override fun compareTo(other: Date): Int
component1
Link copied to clipboard
common
operator fun component1(): Int
component2
Link copied to clipboard
common
operator fun component2(): Month
component3
Link copied to clipboard
common
operator fun component3(): Int
copy
Link copied to clipboard
common

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

fun copy(year: Int, month: Month, dayOfMonth: Int): Date
fun copy(year: Int, monthNumber: Int, dayOfMonth: Int): Date
fun copy(year: Int, dayOfYear: Int): Date
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
minus
Link copied to clipboard
common

Returns this date with period subtracted from it.

Years are added first, then months, then days. If the day exceeds the maximum month length at any step, it will be coerced into the valid range.

operator fun minus(period: Period): Date
operator 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
plus
Link copied to clipboard
common

Returns this date with period added to it.

Years are added first, then months, then days. If the day exceeds the maximum month length at any step, it will be coerced into the valid range.

operator fun plus(period: Period): Date
operator 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
rangeTo
Link copied to clipboard
common
operator fun rangeTo(other: Date): DateRange
toString
Link copied to clipboard
common

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

open override fun toString(): String

Properties

dayOfMonth
Link copied to clipboard
common

The day of the month.

val dayOfMonth: Int
dayOfUnixEpoch
Link copied to clipboard
common

The day of the Unix epoch.

val dayOfUnixEpoch: Long
dayOfWeek
Link copied to clipboard
common

The day of the week.

val dayOfWeek: DayOfWeek
dayOfYear
Link copied to clipboard
common

The day of the year.

val dayOfYear: Int
daysSinceUnixEpoch
Link copied to clipboard
common

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

val daysSinceUnixEpoch: LongDays
month
Link copied to clipboard
common

The month of the year.

val month: Month
monthNumber
Link copied to clipboard
common

The ISO month number, from 1-12.

val monthNumber: Int
year
Link copied to clipboard
common

The year.

val year: Int

Extensions

at
Link copied to clipboard
common

Combines a Date with a Time to create a DateTime.

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

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

infix fun Date.at(offsetTime: OffsetTime): OffsetDateTime
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
downTo
Link copied to clipboard
common

Creates a progression of dates in descending order.

infix fun Date.downTo(to: Date): DateDayProgression
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
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
endOfMonth
Link copied to clipboard
common

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

val Date.endOfMonth: Date
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

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
endOfYear
Link copied to clipboard
common

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

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

Checks if this date falls within a leap year.

val Date.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
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
lengthOfYear
Link copied to clipboard
common

The length of this date's year in days.

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

The next date after this one that falls on dayOfWeek.

fun Date.next(dayOfWeek: DayOfWeek): Date
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
previous
Link copied to clipboard
common

The last date before this one that falls on dayOfWeek.

fun Date.previous(dayOfWeek: DayOfWeek): Date
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
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
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
startOfMonth
Link copied to clipboard
common

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

val Date.startOfMonth: Date
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

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
startOfYear
Link copied to clipboard
common

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

val Date.startOfYear: Date
toJavaLocalDate
Link copied to clipboard

Converts this date to an equivalent Java LocalDate.

fun Date.toJavaLocalDate(): LocalDate
toNSDateComponents
Link copied to clipboard
darwin

Converts this date to an equivalent NSDateComponents object.

fun Date.toNSDateComponents(includeCalendar: Boolean): <ERROR CLASS>
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 date with the precision reduced to the year.

fun Date.toYear(): Year
toYearMonth
Link copied to clipboard
common

Returns this date with the precision reduced to the month.

fun Date.toYearMonth(): YearMonth
until
Link copied to clipboard
common

Creates a DateRange containing all of the days from this date up to, but not including to.

infix fun Date.until(to: Date): DateRange
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

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
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

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

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
weekOfMonth
Link copied to clipboard
common

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

val Date.weekOfMonth: Int

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

fun Date.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
weekOfWeekBasedYear
Link copied to clipboard
common

The week number used in the ISO week date system.

val Date.weekOfWeekBasedYear: Int

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

fun Date.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
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

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

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