class Period
A date-based period of time, such as "2 years, 5 months, 16 days". Unlike Duration, which uses exact increments, a Period works with conceptual days, months, and years, ignoring daylight savings and length differences.
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
days |
The number of days in this period. val days: IntDays |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
months |
The number of months in this period. val months: IntMonths |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
totalMonths |
The total number of months in this period, including years. val totalMonths: LongMonths |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
years |
The number of years in this period. val years: IntYears |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
component1 |
operator fun component1(): IntYears |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
component2 |
operator fun component2(): IntMonths |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
component3 |
operator fun component3(): IntDays |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
copy |
Return a new Period, replacing the years, months, and days components with new values, as desired fun copy(years: IntYears = this.years, months: IntMonths = this.months, days: IntDays = this.days): Period |
(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)
isNegative |
Check if any component of this period is negative. fun isNegative(): Boolean |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
isZero |
Check if this period has no length. fun isZero(): Boolean |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
minus |
Subtract each component of another period from this period. operator fun minus(other: Period): Periodoperator fun minus(years: IntYears): Periodoperator fun minus(months: IntMonths): Periodoperator fun minus(weeks: IntWeeks): Periodoperator fun minus(days: IntDays): Periodoperator fun minus(years: LongYears): Periodoperator fun minus(months: LongMonths): Periodoperator fun minus(weeks: LongWeeks): Periodoperator fun minus(days: LongDays): Period |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
normalized |
Normalize the number of years and months such that "1 year, 15 months" becomes "2 years, 3 months". Only the months and years components are combined. Days are never adjusted. fun normalized(): Period |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
plus |
Add each component of another period to each component of this period. operator fun plus(other: Period): Periodoperator fun plus(years: IntYears): Periodoperator fun plus(months: IntMonths): Periodoperator fun plus(weeks: IntWeeks): Periodoperator fun plus(days: IntDays): Periodoperator fun plus(years: LongYears): Periodoperator fun plus(months: LongMonths): Periodoperator fun plus(weeks: LongWeeks): Periodoperator fun plus(days: LongDays): Period |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
times |
Multiply each component of this period by a scalar value. operator fun times(scalar: Int): Period |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
toString |
Returns an ISO-8601 period representation, such as "P1Y10M3D" fun toString(): String |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
unaryMinus |
Reverse the sign of each component in the period. operator fun unaryMinus(): Period |
(iosArm64, iosX64, jvm, macosX64, tvosArm64, tvosX64, watchosArm64, watchosX86)
ZERO |
A period of no length val ZERO: Period |
(jvm)
toJavaPeriod |
Convert to an equivalent Java fun Period.toJavaPeriod(): Period |