Date¶
@Serializable(with = DateIsoSerializer::class)
class Date(val year: Int, val month: Month, day: Int) : Comparable<Date>
A date in an ambiguous region.
Parameters¶
common
| year | the year |
| month | the month |
| day | the day of the month |
Throws¶
| DateTimeException | if the year or day is invalid |
Constructors¶
| Date | common constructor(year: Int, monthNumber: Int, day: Int)Creates a Date from a year, ISO month number, and day of month. constructor(year: Int, month: Month, day: Int)Creates a Date from a year, month, and day of month. |
Types¶
| Name | Summary |
|---|---|
| Companion | common object Companion |
Properties¶
| Name | Summary |
|---|---|
| dayOfMonth | common val dayOfMonth: IntThe day of the month. |
| dayOfUnixEpoch | common val dayOfUnixEpoch: LongThe day of the Unix epoch. |
| dayOfWeek | common val dayOfWeek: DayOfWeekThe day of the week. |
| dayOfYear | common val dayOfYear: IntThe day of the year. |
| daysSinceUnixEpoch | common val daysSinceUnixEpoch: DaysThe number of days away from the Unix epoch ( 1970-01-01T00:00Z) that this date falls. |
| endOfDay | common val Date.endOfDay: DateTimeThe 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. |
| endOfMonth | common val Date.endOfMonth: DateThe date at the end of the month that this date falls in. |
| endOfWeek | common val Date.endOfWeek: DateThe date at the end of the ISO week that this date falls in. |
| endOfYear | common val Date.endOfYear: DateThe date at the end of the year that this date falls in. |
| isInLeapYear | common val Date.isInLeapYear: BooleanChecks if this date falls within a leap year. |
| isLeapDay | common val Date.isLeapDay: BooleanChecks if this date is February 29. |
| lengthOfMonth | common val Date.lengthOfMonth: DaysThe length of this date's month in days. |
| lengthOfWeekBasedYear | common val Date.lengthOfWeekBasedYear: WeeksThe length of the ISO week-based year that this date falls in, either 52 or 53 weeks. |
| lengthOfYear | common val Date.lengthOfYear: DaysThe length of this date's year in days. |
| month | common val month: MonthThe month of the year. |
| monthNumber | common val monthNumber: IntThe ISO month number, from 1-12. |
| startOfDay | common val Date.startOfDay: DateTimeThe 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. |
| startOfMonth | common val Date.startOfMonth: DateThe date at the start of the month that this date falls in. |
| startOfWeek | common val Date.startOfWeek: DateThe date at the start of the ISO week that this date falls in. |
| startOfYear | common val Date.startOfYear: DateThe date at the start of the year that this date falls in. |
| week | common val Date.week: DateRangeThe range defining the ISO week that this date falls within. |
| weekBasedYear | common val Date.weekBasedYear: IntThe 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. |
| weekOfMonth | common val Date.weekOfMonth: IntThe week of the month, from 0-6, calculated using the ISO week definition. |
| weekOfWeekBasedYear | common val Date.weekOfWeekBasedYear: IntThe week number used in the ISO week date system. |
| weekOfYear | common val Date.weekOfYear: IntThe week of the year, calculated using the ISO week definition. If the week number is associated with the preceding year, 0 will be returned. |
| year | common val year: IntThe year. |
Functions¶
| Name | Summary |
|---|---|
| at | common infix fun Date.at(offsetTime: OffsetTime): OffsetDateTimeCombines a local date with a time and UTC offset to create an OffsetDateTime. common infix fun Date.at(time: Time): DateTimeCombines a Date with a Time to create a DateTime. |
| atTime | common fun Date.atTime(hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0): DateTimeCombines a Date with a time to create a DateTime. |
| compareTo | common open operator override fun compareTo(other: Date): Int |
| component1 | common operator fun component1(): Int |
| component2 | common operator fun component2(): Month |
| component3 | common operator fun component3(): Int |
| copy | common fun copy(year: Int = this.year, dayOfYear: Int): Datefun copy(year: Int = this.year, month: Month = this.month, dayOfMonth: Int = this.day): Datefun copy(year: Int = this.year, monthNumber: Int, dayOfMonth: Int = this.day): DateReturns a copy of this date with the values of any individual components replaced by the new values specified. |
| downTo | common infix fun Date.downTo(to: Date): DateDayProgressionCreates a progression of dates in descending order. |
| endOfDayAt | common fun Date.endOfDayAt(zone: TimeZone): ZonedDateTimeThe ZonedDateTime at the last representable instant of the day in zone, taking into account any daylight savings transitions. |
| endOfWeek | common fun Date.endOfWeek(settings: WeekSettings): DateThe 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. common fun Date.endOfWeek(locale: Locale): DateThe date at the end of the week that this date falls in. The first day of the week will be determined by locale. |
| equals | common open operator override fun equals(other: Any?): Boolean |
| hashCode | common open override fun hashCode(): Int |
| minus | common operator fun minus(centuries: Centuries): DateReturns this date with centuries subtracted from it. common operator fun minus(days: Days): DateReturns this date with days subtracted from it. common operator fun minus(decades: Decades): DateReturns this date with decades subtracted from it. common operator fun minus(months: Months): DateReturns this date with months subtracted from it. common operator fun minus(period: Period): DateReturns this date with period subtracted from it. common operator fun minus(weeks: Weeks): DateReturns this date with weeks subtracted from it. common operator fun minus(years: Years): DateReturns this date with years subtracted from it. |
| next | common fun Date.next(dayOfWeek: DayOfWeek): DateThe next date after this one that falls on dayOfWeek. |
| nextOrSame | common fun Date.nextOrSame(dayOfWeek: DayOfWeek): DateThe next date that falls on dayOfWeek, or this date if it falls on the same day. |
| plus | common operator fun plus(centuries: Centuries): DateReturns this date with centuries added to it. common operator fun plus(days: Days): DateReturns this date with days added to it. common operator fun plus(decades: Decades): DateReturns this date with decades added to it. common operator fun plus(months: Months): DateReturns this date with months added to it. common operator fun plus(period: Period): DateReturns this date with period added to it. common operator fun plus(weeks: Weeks): DateReturns this date with weeks added to it. common operator fun plus(years: Years): DateReturns this date with years added to it. |
| previous | common fun Date.previous(dayOfWeek: DayOfWeek): DateThe last date before this one that falls on dayOfWeek. |
| previousOrSame | common fun Date.previousOrSame(dayOfWeek: DayOfWeek): DateThe previous date that falls on dayOfWeek, or this date if it falls on the same day. |
| rangeTo | common operator fun rangeTo(other: Date): DateRange |
| startOfDayAt | common fun Date.startOfDayAt(zone: TimeZone): ZonedDateTimeThe ZonedDateTime at the start of the day in zone, taking into account any daylight savings transitions. |
| startOfWeek | common fun Date.startOfWeek(settings: WeekSettings): DateThe date at the start of the week that this date falls in. The first day of the week will be determined by settings. common fun Date.startOfWeek(locale: Locale): DateThe date at the start of the week that this date falls in. The first day of the week will be determined by locale. |
| toJavaLocalDate | jvm fun Date.toJavaLocalDate(): LocalDateConverts this date to an equivalent Java LocalDate. |
| toNSDateComponents | darwin fun Date.toNSDateComponents(includeCalendar: Boolean = false): <Error class: unknown class>Converts this date to an equivalent NSDateComponents object. |
| toString | common open override fun toString(): StringConverts this date to a string in ISO-8601 extended format using the "calendar date" form. For example, 2012-04-15. |
| toWeekDate | common inline fun <T> Date.toWeekDate(action: (year: Int, week: Int, day: Int) -> T): TConverts this date to an ISO week date representation. common inline fun <T> Date.toWeekDate(settings: WeekSettings, action: (year: Int, week: Int, day: Int) -> T): TConverts this date to a week date representation using the week definition in settings. common inline fun <T> Date.toWeekDate(locale: Locale, action: (year: Int, week: Int, day: Int) -> T): TConverts this date to a week date representation using the week definition associated with the provided locale. |
| toYear | common fun Date.toYear(): YearReturns this date with the precision reduced to the year. |
| toYearMonth | common fun Date.toYearMonth(): YearMonthReturns this date with the precision reduced to the month. |
| until | common infix fun Date.until(to: Date): DateRangeCreates a DateRange containing all the days from this date up to, but not including to. |
| week | common fun Date.week(settings: WeekSettings): DateRangeThe range defining the week that this date falls within. The first day of the week will be determined by the provided settings. common fun Date.week(locale: Locale): DateRangeThe range defining the week that this date falls within. The first day of the week will be the default associated with the provided locale. |
| weekBasedYear | common fun Date.weekBasedYear(settings: WeekSettings): IntThe 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. common fun Date.weekBasedYear(locale: Locale): IntThe 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. |
| weekOfMonth | common fun Date.weekOfMonth(settings: WeekSettings): IntThe week of the month, from 0-6, calculated using the week definition in settings. common fun Date.weekOfMonth(locale: Locale): IntThe week of the month, from 0-6, calculated using the default week definition associated with the provided locale. |
| weekOfWeekBasedYear | common fun Date.weekOfWeekBasedYear(settings: WeekSettings): IntThe week number of the week-based year, calculated using the week definition in settings. common fun Date.weekOfWeekBasedYear(locale: Locale): IntThe week number of the week-based year, calculated using the week definition associated with the provided locale. |
| weekOfYear | common fun Date.weekOfYear(settings: WeekSettings): IntThe 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.common fun Date.weekOfYear(locale: Locale): IntThe 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. |