Date

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

A date in an ambiguous region.

Parameters

year

the year

month

the month

day

the day of the month

Throws

if the year or day is invalid

Constructors

Date
Link copied to clipboard
common
fun Date(year: Int, monthNumber: Int, day: Int)
Creates a Date from a year, ISO month number, and day of month.
Date
Link copied to clipboard
common
fun Date(year: Int, month: Month, day: Int)
Creates a Date from a year, month, and day of month.

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
fun copy(year: Int = this.year, dayOfYear: Int = this.dayOfYear): Date
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
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, monthNumber: Int, dayOfMonth: Int = this.day): Date
Returns a copy of this date with the values of any individual components replaced by the new values specified.
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
operator fun minus(days: IntDays): Date
operator fun minus(months: IntMonths): Date
operator fun minus(weeks: IntWeeks): Date
operator fun minus(years: IntYears): Date
operator fun minus(days: LongDays): Date
operator fun minus(months: LongMonths): Date
operator fun minus(weeks: LongWeeks): Date
operator fun minus(years: LongYears): Date
operator fun minus(period: Period): Date
Returns this date with period subtracted from it.
plus
Link copied to clipboard
common
operator fun plus(days: IntDays): Date
operator fun plus(months: IntMonths): Date
operator fun plus(weeks: IntWeeks): Date
operator fun plus(years: IntYears): Date
operator fun plus(days: LongDays): Date
operator fun plus(months: LongMonths): Date
operator fun plus(weeks: LongWeeks): Date
operator fun plus(years: LongYears): Date
operator fun plus(period: Period): Date
Returns this date with period added to it.
rangeTo
Link copied to clipboard
common
operator fun rangeTo(other: Date): DateRange
toString
Link copied to clipboard
common
open override fun toString(): String
Converts this date to a string in ISO-8601 extended format using the "calendar date" form.

Properties

dayOfMonth
Link copied to clipboard
common
val dayOfMonth: Int
The day of the month.
dayOfUnixEpoch
Link copied to clipboard
common
val dayOfUnixEpoch: Long
The day of the Unix epoch.
dayOfWeek
Link copied to clipboard
common
val dayOfWeek: DayOfWeek
The day of the week.
dayOfYear
Link copied to clipboard
common
val dayOfYear: Int
The day of the year.
daysSinceUnixEpoch
Link copied to clipboard
common
val daysSinceUnixEpoch: LongDays
The number of days away from the Unix epoch (1970-01-01T00:00Z) that this date falls.
month
Link copied to clipboard
common
val month: Month
The month of the year.
monthNumber
Link copied to clipboard
common
val monthNumber: Int
The ISO month number, from 1-12.
year
Link copied to clipboard
common
val year: Int
The year.

Extensions

at
Link copied to clipboard
common
infix fun Date.at(time: Time): DateTime
Combines a Date with a Time to create a DateTime.
infix fun Date.at(offsetTime: OffsetTime): OffsetDateTime
Combines a local date with a time and UTC offset to create an OffsetDateTime.
atTime
Link copied to clipboard
common
fun Date.atTime(hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0): DateTime
Combines a Date with a time to create a DateTime.
downTo
Link copied to clipboard
common
infix fun Date.downTo(to: Date): DateDayProgression
Creates a progression of dates in descending order.
endOfDay
Link copied to clipboard
common
val Date.endOfDay: DateTime
The DateTime at the last representable instant of the day.
endOfDayAt
Link copied to clipboard
common
fun Date.endOfDayAt(zone: TimeZone): ZonedDateTime
The ZonedDateTime at the last representable instant of the day in zone, taking into account any daylight savings transitions.
endOfMonth
Link copied to clipboard
common
val Date.endOfMonth: Date
The date at the end of the month that this date falls in.
endOfWeek
Link copied to clipboard
common
val Date.endOfWeek: Date
The date at the end of the ISO week that this date falls in.
fun Date.endOfWeek(settings: WeekSettings): Date
The date at the end of the week that this date falls in.
fun Date.endOfWeek(locale: Locale): Date
The date at the end of the week that this date falls in.
endOfYear
Link copied to clipboard
common
val Date.endOfYear: Date
The date at the end of the year that this date falls in.
isInLeapYear
Link copied to clipboard
common
val Date.isInLeapYear: Boolean
Checks if this date falls within a leap year.
isLeapDay
Link copied to clipboard
common
val Date.isLeapDay: Boolean
Checks if this date is February 29.
lengthOfMonth
Link copied to clipboard
common
val Date.lengthOfMonth: IntDays
The length of this date's month in days.
lengthOfWeekBasedYear
Link copied to clipboard
common
val Date.lengthOfWeekBasedYear: IntWeeks
The length of the ISO week-based year that this date falls in, either 52 or 53 weeks.
lengthOfYear
Link copied to clipboard
common
val Date.lengthOfYear: IntDays
The length of this date's year in days.
next
Link copied to clipboard
common
fun Date.next(dayOfWeek: DayOfWeek): Date
The next date after this one that falls on dayOfWeek.
nextOrSame
Link copied to clipboard
common
fun Date.nextOrSame(dayOfWeek: DayOfWeek): Date
The next date that falls on dayOfWeek, or this date if it falls on the same day.
previous
Link copied to clipboard
common
fun Date.previous(dayOfWeek: DayOfWeek): Date
The last date before this one that falls on dayOfWeek.
previousOrSame
Link copied to clipboard
common
fun Date.previousOrSame(dayOfWeek: DayOfWeek): Date
The previous date that falls on dayOfWeek, or this date if it falls on the same day.
startOfDay
Link copied to clipboard
common
val Date.startOfDay: DateTime
The DateTime at the start of the day.
startOfDayAt
Link copied to clipboard
common
fun Date.startOfDayAt(zone: TimeZone): ZonedDateTime
The ZonedDateTime at the start of the day in zone, taking into account any daylight savings transitions.
startOfMonth
Link copied to clipboard
common
val Date.startOfMonth: Date
The date at the start of the month that this date falls in.
startOfWeek
Link copied to clipboard
common
val Date.startOfWeek: Date
The date at the start of the ISO week that this date falls in.
fun Date.startOfWeek(settings: WeekSettings): Date
The date at the start of the week that this date falls in.
fun Date.startOfWeek(locale: Locale): Date
The date at the start of the week that this date falls in.
startOfYear
Link copied to clipboard
common
val Date.startOfYear: Date
The date at the start of the year that this date falls in.
toJavaLocalDate
Link copied to clipboard
fun Date.toJavaLocalDate(): LocalDate
Converts this date to an equivalent Java LocalDate.
toNSDateComponents
Link copied to clipboard
darwin
fun Date.toNSDateComponents(includeCalendar: Boolean = false): <ERROR CLASS>
Converts this date to an equivalent NSDateComponents object.
toWeekDate
Link copied to clipboard
common
inline fun <T> Date.toWeekDate(action: (year: Int, week: Int, day: Int) -> T): T
Converts this date to an ISO week date representation.
inline fun <T> Date.toWeekDate(settings: WeekSettings, action: (year: Int, week: Int, day: Int) -> T): T
Converts this date to a week date representation using the week definition in settings.
inline fun <T> Date.toWeekDate(locale: Locale, action: (year: Int, week: Int, day: Int) -> T): T
Converts this date to a week date representation using the week definition associated with the provided locale.
toYear
Link copied to clipboard
common
fun Date.toYear(): Year
Returns this date with the precision reduced to the year.
toYearMonth
Link copied to clipboard
common
fun Date.toYearMonth(): YearMonth
Returns this date with the precision reduced to the month.
until
Link copied to clipboard
common
infix fun Date.until(to: Date): DateRange
Creates a DateRange containing all of the days from this date up to, but not including to.
week
Link copied to clipboard
common
val Date.week: DateRange
The range defining the ISO week that this date falls within.
fun Date.week(settings: WeekSettings): DateRange
The range defining the week that this date falls within.
fun Date.week(locale: Locale): DateRange
The range defining the week that this date falls within.
weekBasedYear
Link copied to clipboard
common
val Date.weekBasedYear: Int
The week-based year used in the ISO week date system.
fun Date.weekBasedYear(settings: WeekSettings): Int
The week-based year, calculated using the week definition in settings.
fun Date.weekBasedYear(locale: Locale): Int
The week-based year, calculated using the week definition associated with the provided locale.
weekOfMonth
Link copied to clipboard
common
val Date.weekOfMonth: Int
The week of the month, from 0-6, calculated using the ISO week definition.
fun Date.weekOfMonth(settings: WeekSettings): Int
The week of the month, from 0-6, calculated using the week definition in settings.
fun Date.weekOfMonth(locale: Locale): Int
The week of the month, from 0-6, calculated using the default week definition associated with the provided locale.
weekOfWeekBasedYear
Link copied to clipboard
common
val Date.weekOfWeekBasedYear: Int
The week number used in the ISO week date system.
fun Date.weekOfWeekBasedYear(settings: WeekSettings): Int
The week number of the week-based year, calculated using the week definition in settings.
fun Date.weekOfWeekBasedYear(locale: Locale): Int
The week number of the week-based year, calculated using the week definition associated with the provided locale.
weekOfYear
Link copied to clipboard
common
val Date.weekOfYear: Int
The week of the year, calculated using the ISO week definition.
fun Date.weekOfYear(settings: WeekSettings): Int
The week of the year, calculated using the week definition in settings.
fun Date.weekOfYear(locale: Locale): Int
The week of the year, calculated using the week definition associated with the provided locale.