lucee.Componentwirebox.system.async.time.Period
A date-based amount of time in the ISO-8601 calendar system, such as '2 years, 3 months and 4 days'. This class models a quantity or amount of time in terms of years, months and days. See Duration for the time-based equivalent to this class. Durations and periods differ in their treatment of daylight savings time when added to ZonedDateTime. A Duration will add an exact number of seconds, thus a duration of one day is always exactly 24 hours. By contrast, a Period will add a conceptual day, trying to maintain the local time. For example, consider adding a period of one day and a duration of one day to 18:00 on the evening before a daylight savings gap. The Period will add the conceptual day and result in a ZonedDateTime at 18:00 the following day. By contrast, the Duration will add exactly 24 hours, resulting in a ZonedDateTime at 19:00 the following day (assuming a one hour DST gap).
Constructor Summary | |
---|---|
init([any years='0'], [any months='0'], [any days='0'])
Initialize to zero date base period. |
Method Summary | |
---|---|
any
|
addTo(any target, [boolean asNative='false'])
Adds this period to the specified temporal object and return back to you a date/time object. |
Period
|
between(any start, any end)
Obtains a Duration representing the duration between two temporal date objects. |
any
|
from(Period amount)
Obtains an instance of Period from another period. |
numeric
|
get([any unit='days'])
Gets the value of the requested unit in seconds by default (days) or years, months, days. |
any
|
getChronology()
Gets the chronology of this period, which is the ISO calendar system. |
numeric
|
getDays()
Gets the number of Days in this period. |
numeric
|
getMonths()
Gets the number of Months in this period. |
any
|
getNative()
Get the native java class we proxy to. |
array
|
getUnits()
Gets the set (array) of units supported by this period. |
numeric
|
getYears()
Gets the number of Years in this period. |
boolean
|
isEquals(Period otherPeriod)
Checks if this period is equal to the specified period. |
boolean
|
isNegative()
Checks if the period is negative, excluding zero. |
boolean
|
isZero()
Checks if the period is zero length. |
Period
|
minus(Period amountToSubtract)
Returns a copy of this period with the specified period subtracted. |
Period
|
minusDays(any daysToSubtract)
|
Period
|
minusMonths(any monthsToSubtract)
|
Period
|
minusYears(any yearsToSubtract)
|
Period
|
multipliedBy(any scalar)
|
Period
|
negated()
Returns a copy of this duration with the length negated. |
Period
|
normalized()
Returns a copy of this period with the years and months normalized. |
Period
|
of([any years='0'], [any months='0'], [any days='0'])
Obtains a Period representing an amount in the specified arguments. |
Period
|
ofDays(any days)
Obtains a Period representing a number of days. |
Period
|
ofMonths(any months)
Obtains a Period representing a number of months. |
Period
|
ofWeeks(any weeks)
Obtains a Period representing a number of weeks. |
Period
|
ofYears(any years)
Obtains a Period representing a number of years. |
Period
|
parse(any text)
Obtains a Period from a text string such as PnYnMnD. |
Period
|
plus(Period amountToAdd)
Returns a copy of this period with the specified period added. |
Period
|
plusDays(any daysToAdd)
|
Period
|
plusMonths(any monthsToAdd)
|
Period
|
plusYears(any yearsToAdd)
|
any
|
subtractFrom(any target, [boolean asNative='false'])
Subtracts this period to the specified temporal object and return back to you a date/time object or a Java LocalDate object. |
string
|
toString()
Outputs this period as a String, such as P6Y3M1D. |
numeric
|
toTotalMonths()
Gets the total number of months in this period. |
any
|
withDays(any days)
Returns a copy of this period with the specified amount of days. |
any
|
withMonths(any months)
Returns a copy of this period with the specified amount of months. |
any
|
withYears(any years)
Returns a copy of this period with the specified amount of years. |
Methods inherited from class lucee.Component |
---|
None |
Constructor Detail |
---|
Initialize to zero date base period
years
- The yearsmonths
- The monthsdays
- The daysMethod Detail |
---|
Adds this period to the specified temporal object and return back to you a date/time object
target
- The date/time object or string to incorporate the period intoasNative
- If true, we will give you the java.time.LocalDate object, else a ColdFusion date/time stringObtains a Duration representing the duration between two temporal date objects. This calculates the duration between two temporal objects. If the objects are of different types, then the duration is calculated based on the type of the first object. For example, if the first argument is a LocalTime then the second argument is converted to a LocalTime.
start
- The start date/time objectend
- The end date/time objectObtains an instance of Period from another period
amount
- The periodGets the value of the requested unit in seconds by default (days) or years, months, days
unit
- years, months, daysGets the chronology of this period, which is the ISO calendar system.
Gets the number of Days in this period.
Gets the number of Months in this period.
Get the native java class we proxy to.
Gets the set (array) of units supported by this period.
Gets the number of Years in this period.
Checks if this period is equal to the specified period.
otherPeriod
- The period to compare againstChecks if the period is negative, excluding zero
Checks if the period is zero length
Returns a copy of this period with the specified period subtracted.
amountToSubtract
- The period to subtractdaysToSubtract
monthsToSubtract
yearsToSubtract
scalar
Returns a copy of this duration with the length negated.
Returns a copy of this period with the years and months normalized.
Obtains a Period representing an amount in the specified arguments
years
- The yearsmonths
- The monthsdays
- The daysObtains a Period representing a number of days.
days
- The number of days, positive or negativeObtains a Period representing a number of months.
months
- The number of months, positive or negativeObtains a Period representing a number of weeks.
weeks
- The number of weeks, positive or negativeObtains a Period representing a number of years.
years
- The number of years, positive or negativeObtains a Period from a text string such as PnYnMnD. This will parse the string produced by toString() which is based on the ISO-8601 period formats PnYnMnD and PnW. Examples: "P2Y" -- Period.ofYears(2) "P3M" -- Period.ofMonths(3) "P4W" -- Period.ofWeeks(4) "P5D" -- Period.ofDays(5) "P1Y2M3D" -- Period.of(1, 2, 3) "P1Y2M3W4D" -- Period.of(1, 2, 25) "P-1Y2M" -- Period.of(-1, 2, 0) "-P1Y2M" -- Period.of(-1, -2, 0)
text
- The string to parse and build up to a periodReturns a copy of this period with the specified period added.
amountToAdd
- The period to AdddaysToAdd
monthsToAdd
yearsToAdd
Subtracts this period to the specified temporal object and return back to you a date/time object or a Java LocalDate object
target
- The date/time object or string to incorporate the period intoasNative
- If true, we will give you the java.time.LocalDate object, else a ColdFusion date/time stringOutputs this period as a String, such as P6Y3M1D.
Gets the total number of months in this period.
Returns a copy of this period with the specified amount of days.
days
- The daysReturns a copy of this period with the specified amount of months.
months
- The monthsReturns a copy of this period with the specified amount of years.
years
- The years