Type Hierarchy:
Satisfied Interfaces: Comparable<Period>, PeriodBehavior<Period>, ReadableDatePeriod, ReadablePeriod, ReadableTimePeriod, Scalable<Integer,Period>, Summable<Period>

An immutable period consisting of the ISO-8601 years, months, days, hours, minutes, seconds and milliseconds, such as '3 Months, 4 Days and 7 Hours'.

A period is a human-scale description of an amount of time.

Initializer
Period(Integer years = 0, Integer months = 0, Integer days = 0, Integer hours = 0, Integer minutes = 0, Integer seconds = 0, Integer milliseconds = 0)
Parameters:
  • years = 0

    The number of years.

  • months = 0

    The number of months.

  • days = 0

    The number of days.

  • hours = 0

    The number of hours.

  • minutes = 0

    The number of minutes.

  • seconds = 0

    The number of seconds.

  • milliseconds = 0

    The number of milliseconds.

Attributes
dateOnlySource Code
shared actual ReadableDatePeriod dateOnly

Returns a date only view of this period.

Refined declaration: dateOnly
daysSource Code
shared actual Integer days

The number of days.

Refined declaration: days
hashSource Code
shared actual Integer hash

This implementation respect the constraint that if x==y then x.hash==y.hash.

Refined declaration: hash
hoursSource Code
shared actual Integer hours

The number of hours.

Refined declaration: hours
millisecondsSource Code
shared actual Integer milliseconds

The number of milliseconds.

Refined declaration: milliseconds
minutesSource Code
shared actual Integer minutes

The number of minutes.

Refined declaration: minutes
monthsSource Code
shared actual Integer months

The number of months.

Refined declaration: months
secondsSource Code
shared actual Integer seconds

The number of seconds.

Refined declaration: seconds
stringSource Code
shared actual String string

Returns the ISO-8601 formatted string for this period.

Refined declaration: string
timeOnlySource Code
shared actual ReadableTimePeriod timeOnly

Returns a time only view of this period.

Refined declaration: timeOnly
yearsSource Code
shared actual Integer years

The number of years.

Refined declaration: years
Inherited Attributes
Attributes inherited from: ReadableDatePeriod
Attributes inherited from: ReadablePeriod
Attributes inherited from: ReadableTimePeriod
Methods
compareSource Code
shared actual Comparison compare(Period other)

Return the result of comparing this period to the other period.

Refined declaration: compare
equalsSource Code
shared actual Boolean equals(Object that)

Checks if this period is equal to another period.

Refined declaration: equals
isZeroSource Code
shared Boolean isZero()

Checks if this period is zero-length.

minusDaysSource Code
shared actual Period minusDays(Integer days)

Returns a copy of this period with the specified number of days subtracted.

Refined declaration: minusDays
minusHoursSource Code
shared actual Period minusHours(Integer hours)

Returns a copy of this period with the specified number of hours subtracted.

Refined declaration: minusHours
minusMillisecondsSource Code
shared actual Period minusMilliseconds(Integer milliseconds)

Returns a copy of this period with the specified number of milliseconds subtracted.

Refined declaration: minusMilliseconds
minusMinutesSource Code
shared actual Period minusMinutes(Integer minutes)

Returns a copy of this period with the specified number of minutes subtracted.

Refined declaration: minusMinutes
minusMonthsSource Code
shared actual Period minusMonths(Integer months)

Returns a copy of this period with the specified number of months subtracted.

Refined declaration: minusMonths
minusSecondsSource Code
shared actual Period minusSeconds(Integer seconds)

Returns a copy of this period with the specified number of seconds subtracted.

Refined declaration: minusSeconds
minusYearsSource Code
shared actual Period minusYears(Integer years)

Returns a copy of this period with the specified number of years subtracted.

Refined declaration: minusYears
normalizedSource Code
shared actual Period normalized()

Returns a copy of this period with all amounts normalized to the standard ranges for date/time fields.

Two normalizations occur, one for years and months, and one for hours, minutes, seconds and milliseconds.

Days are not normalized, as a day may vary in length at daylight savings cutover. Neither is days normalized into months, as number of days per month varies from month to another and depending on the leap year.

Refined declaration: normalized
plusSource Code
shared actual Period plus(Period other)

Returns a new period that is a sum of the two periods.

Refined declaration: plus
plusDaysSource Code
shared actual Period plusDays(Integer days)

Returns a copy of this period with the specified number of days added.

Refined declaration: plusDays
plusHoursSource Code
shared actual Period plusHours(Integer hours)

Returns a copy of this period with the specified number of hours added.

Refined declaration: plusHours
plusMillisecondsSource Code
shared actual Period plusMilliseconds(Integer milliseconds)

Returns a copy of this period with the specified number of milliseconds added.

Refined declaration: plusMilliseconds
plusMinutesSource Code
shared actual Period plusMinutes(Integer minutes)

Returns a copy of this period with the specified number of minutes added.

Refined declaration: plusMinutes
plusMonthsSource Code
shared actual Period plusMonths(Integer months)

Returns a copy of this period with the specified number of months added.

Refined declaration: plusMonths
plusSecondsSource Code
shared actual Period plusSeconds(Integer seconds)

Returns a copy of this period with the specified number of seconds added.

Refined declaration: plusSeconds
plusYearsSource Code
shared actual Period plusYears(Integer years)

Returns a copy of this period with the specified number of years added.

Refined declaration: plusYears
scaleSource Code
shared actual Period scale(Integer scale)

Each field will be scalable independently, and the result will not be normalized

Refined declaration: scale
withDaysSource Code
shared actual Period withDays(Integer days)

Returns a copy of this period with the specified amount of days.

Refined declaration: withDays
withHoursSource Code
shared actual Period withHours(Integer hours)

Returns a copy of this period with the specified amount of hours.

Refined declaration: withHours
withMillisecondsSource Code
shared actual Period withMilliseconds(Integer milliseconds)

Returns a copy of this period with the specified amount of milliseconds.

Refined declaration: withMilliseconds
withMinutesSource Code
shared actual Period withMinutes(Integer minutes)

Returns a copy of this period with the specified amount of minutes.

Refined declaration: withMinutes
withMonthsSource Code
shared actual Period withMonths(Integer months)

Returns a copy of this period with the specified amount of months.

Refined declaration: withMonths
withSecondsSource Code
shared actual Period withSeconds(Integer seconds)

Returns a copy of this period with the specified amount of seconds.

Refined declaration: withSeconds
withYearsSource Code
shared actual Period withYears(Integer years)

Returns a copy of this period with the specified amount of years.

Refined declaration: withYears
Inherited Methods
Methods inherited from: Comparable<Other>
compare
Methods inherited from: PeriodBehavior<Self>
Methods inherited from: Scalable<Scale,Value>
scale
Methods inherited from: Summable<Other>
plus