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.

no subtypes hierarchy

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 Codeshared actual ReadableDatePeriod dateOnly

Returns a date only view of this period.

daysSource Codeshared actual Integer days

The number of days.

hashSource Codeshared actual Integer hash

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

Refines Identifiable.hash ultimately refines Object.hash
hoursSource Codeshared actual Integer hours

The number of hours.

millisecondsSource Codeshared actual Integer milliseconds

The number of milliseconds.

minutesSource Codeshared actual Integer minutes

The number of minutes.

monthsSource Codeshared actual Integer months

The number of months.

secondsSource Codeshared actual Integer seconds

The number of seconds.

stringSource Codeshared actual String string

Returns the ISO-8601 formatted string for this period.

timeOnlySource Codeshared actual ReadableTimePeriod timeOnly

Returns a time only view of this period.

yearsSource Codeshared actual Integer years

The number of years.

Inherited Attributes
Attributes inherited from: ReadableDatePeriod
Attributes inherited from: ReadablePeriod
Attributes inherited from: ReadableTimePeriod
Methods
compareSource Codeshared actual Comparison compare(Period other)

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

equalsSource Codeshared actual Boolean equals(Object that)

Checks if this period is equal to another period.

Refines Identifiable.equals ultimately refines Object.equals
isZeroSource Codeshared Boolean isZero()

Checks if this period is zero-length.

minusDaysSource Codeshared actual Period minusDays(Integer days)

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

minusHoursSource Codeshared actual Period minusHours(Integer hours)

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

minusMillisecondsSource Codeshared actual Period minusMilliseconds(Integer milliseconds)

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

minusMinutesSource Codeshared actual Period minusMinutes(Integer minutes)

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

minusMonthsSource Codeshared actual Period minusMonths(Integer months)

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

minusSecondsSource Codeshared actual Period minusSeconds(Integer seconds)

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

minusYearsSource Codeshared actual Period minusYears(Integer years)

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

normalizedSource Codeshared 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.

plusSource Codeshared actual Period plus(Period other)

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

plusDaysSource Codeshared actual Period plusDays(Integer days)

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

plusHoursSource Codeshared actual Period plusHours(Integer hours)

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

plusMillisecondsSource Codeshared actual Period plusMilliseconds(Integer milliseconds)

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

plusMinutesSource Codeshared actual Period plusMinutes(Integer minutes)

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

plusMonthsSource Codeshared actual Period plusMonths(Integer months)

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

plusSecondsSource Codeshared actual Period plusSeconds(Integer seconds)

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

plusYearsSource Codeshared actual Period plusYears(Integer years)

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

scaleSource Codeshared actual Period scale(Integer scale)

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

withDaysSource Codeshared actual Period withDays(Integer days)

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

withHoursSource Codeshared actual Period withHours(Integer hours)

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

withMillisecondsSource Codeshared actual Period withMilliseconds(Integer milliseconds)

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

withMinutesSource Codeshared actual Period withMinutes(Integer minutes)

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

withMonthsSource Codeshared actual Period withMonths(Integer months)

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

withSecondsSource Codeshared actual Period withSeconds(Integer seconds)

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

withYearsSource Codeshared actual Period withYears(Integer years)

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

Inherited Methods
Methods inherited from: Comparable<Other>
Methods inherited from: PeriodBehavior<Self>
Methods inherited from: Scalable<Scale,Value>
Methods inherited from: Summable<Other>