lucee.Componentcoldbox.system.async.time.Duration
A time-based amount of time, such as '34.5 seconds'. This class models a quantity or amount of time in terms of seconds and nanoseconds. It can be accessed using other duration-based units, such as minutes and hours. In addition, the DAYS unit can be used and is treated as exactly equal to 24 hours, thus ignoring daylight savings effects. See Period for the date-based equivalent to this class. Static class to map to the Java JDK Duration static class with some CF Goodness
Constructor Summary | |
---|---|
init()
Initialize to zero. |
Method Summary | |
---|---|
Duration
|
abs()
Returns a copy of this duration with a positive length. |
any
|
addTo(any target, [boolean asInstant='false'])
Adds this duration to the specified temporal object and return back to you a date/time object. |
Duration
|
between(any start, any end)
Obtains a Duration representing the duration between two temporal date objects. |
any
|
compareTo(Duration otherDuration)
Compares this duration to the specified Duration. |
Duration
|
dividedBy(any divisor)
Returns a copy of this duration divided by the specified value. |
any
|
from(Duration amount)
Obtains an instance of Duration from another duration. |
numeric
|
get([any unit='seconds'])
Gets the value of the requested unit in seconds by default or by nanoseconds. |
numeric
|
getNano()
Gets the number of nano seconds in this duration. |
any
|
getNative()
Get the native java class we proxy to. |
numeric
|
getSeconds()
Gets the number of seconds in this duration. |
array
|
getUnits()
Gets the set (array) of units supported by this duration. |
boolean
|
isEquals(Duration otherDuration)
Checks if this duration is equal to the specified Duration. |
boolean
|
isNegative()
Checks if the duration is negative, excluding zero. |
boolean
|
isZero()
Checks if the duration is zero length. |
Duration
|
minus(any amountToSubtract, [any unit='seconds'])
Returns a copy of this duration with the specified duration subtracted. |
Duration
|
minusDays(any daysToSubtract)
|
Duration
|
minusHours(any hoursToSubtract)
|
Duration
|
minusMillis(any millisToSubtract)
|
Duration
|
minusMinutes(any minutesToSubtract)
|
Duration
|
minusNanos(any nanosToSubtract)
|
Duration
|
minusSeconds(any secondsToSubtract)
|
Duration
|
multipliedBy(any multiplicand)
|
Duration
|
negated()
Returns a copy of this duration with the length negated. |
Duration
|
of(any amount, [any unit='seconds'])
Obtains a Duration representing an amount in the specified unit (seconds). |
Duration
|
ofDays(any days)
Obtains a Duration representing a number of standard 24 hour days. |
Duration
|
ofHours(any hours)
Obtains a Duration representing a number of standard hours. |
Duration
|
ofMillis(any millis)
Obtains a Duration representing a number of standard milliseconds. |
Duration
|
ofMinutes(any minutes)
Obtains a Duration representing a number of standard minutes. |
Duration
|
ofNanos(any nanos)
Obtains a Duration representing a number of standard nanoseconds. |
Duration
|
ofSeconds(any seconds, [any nanoAdjustment])
Obtains a Duration representing a number of seconds and/or an adjustment in nanoseconds. |
Duration
|
parse(any text)
Obtains a Duration from a text string such as PnDTnHnMn. |
Duration
|
plus(any amountToAdd, [any unit='seconds'])
Returns a copy of this duration with the specified duration added. |
Duration
|
plusDays(any daysToAdd)
|
Duration
|
plusHours(any hoursToAdd)
|
Duration
|
plusMillis(any millisToAdd)
|
Duration
|
plusMinutes(any minutesToAdd)
|
Duration
|
plusNanos(any nanosToAdd)
|
Duration
|
plusSeconds(any secondsToAdd)
|
any
|
subtractFrom(any target, [boolean asInstant='false'])
Subtracts this duration to the specified temporal object and return back to you a date/time object. |
numeric
|
toDays()
Gets the number of days in this duration. |
numeric
|
toDaysPart()
Extracts the number of days in the duration. |
numeric
|
toHours()
Gets the number of Hours in this duration. |
numeric
|
toHoursPart()
Extracts the number of HoursPart in this duration. |
numeric
|
toMillis()
Gets the number of Millis in this duration. |
numeric
|
toMillisPart()
Extracts the number of MillisPart in this duration. |
numeric
|
toMinutes()
Gets the number of Minutes in this duration. |
numeric
|
toMinutesPart()
Extracts the number of MinutesPart in this duration. |
numeric
|
toNanos()
Gets the number of Nanos in this duration. |
numeric
|
toNanosPart()
Extracts the number of NanosPart in this duration. |
numeric
|
toSeconds()
Gets the number of Seconds in this duration. |
numeric
|
toSecondsPart()
Extracts the number of SecondsPart in this duration. |
string
|
toString()
A string representation of this duration using ISO-8601 seconds based representation, such as PT8H6M12. |
any
|
withNanos(any nanoOfSecond)
Returns a copy of this duration with the specified nano-of-second. |
any
|
withSeconds(any seconds)
Returns a copy of this duration with the specified amount of seconds. |
Methods inherited from class lucee.Component |
---|
None |
Constructor Detail |
---|
Initialize to zero
Method Detail |
---|
Returns a copy of this duration with a positive length.
Adds this duration to the specified temporal object and return back to you a date/time object
target
- The date/time object or string to incorporate the duration intoasInstant
- Return the result either as a date/time string or a java.time.Instant objectObtains 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 objectCompares this duration to the specified Duration. The comparison is based on the total length of the durations. It is "consistent with equals", as defined by Comparable.
otherDuration
- the other duration to compare toReturns a copy of this duration divided by the specified value.
divisor
- Divide by what?Obtains an instance of Duration from another duration
amount
- trueGets the value of the requested unit in seconds by default or by nanoseconds
unit
- Seconds or nanoGets the number of nano seconds in this duration.
Get the native java class we proxy to.
Gets the number of seconds in this duration.
Gets the set (array) of units supported by this duration.
Checks if this duration is equal to the specified Duration.
otherDuration
- The duration to compare againstChecks if the duration is negative, excluding zero
Checks if the duration is zero length
Returns a copy of this duration with the specified duration subtracted.
amountToSubtract
- The amount to subtractunit
- The units to usedaysToSubtract
hoursToSubtract
millisToSubtract
minutesToSubtract
nanosToSubtract
secondsToSubtract
multiplicand
Returns a copy of this duration with the length negated.
Obtains a Duration representing an amount in the specified unit (seconds)
amount
- the amount of the duration, measured in terms of the unit, positive or negativeunit
- The time unit: CENTURIES,DAYS,DECADES,ERAS,FOREVER,HALF_DAYS,HOURS,MICROS,MILLENNIA,MILLIS,MINUTES,MONTHS,NANOS,SECONDS,WEEKS,YEARSObtains a Duration representing a number of standard 24 hour days.
days
- The number of days, positive or negativeObtains a Duration representing a number of standard hours.
hours
- The number of hours, positive or negativeObtains a Duration representing a number of standard milliseconds
millis
- The number of millis, positive or negativeObtains a Duration representing a number of standard minutes
minutes
- The number of minutes, positive or negativeObtains a Duration representing a number of standard nanoseconds
nanos
- The number of nanos, positive or negativeObtains a Duration representing a number of seconds and/or an adjustment in nanoseconds. This method allows an arbitrary number of nanoseconds to be passed in. The factory will alter the values of the second and nanosecond in order to ensure that the stored nanosecond is in the range 0 to 999,999,999. For example, the following will result in exactly the same duration:
seconds
- The number of seconds, positive or negativenanoAdjustment
- the nanosecond adjustment to the number of seconds, positive or negativeObtains a Duration from a text string such as PnDTnHnMn.nS. This will parse a textual representation of a duration, including the string produced by toString(). The formats accepted are based on the ISO-8601 duration format PnDTnHnMn.nS with days considered to be exactly 24 hours. Examples: "PT20.345S" -- parses as "20.345 seconds" "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds) "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds) "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds) "P2DT3H4M" -- parses as "2 days, 3 hours and 4 minutes" "PT-6H3M" -- parses as "-6 hours and +3 minutes" "-PT6H3M" -- parses as "-6 hours and -3 minutes" "-PT-6H+3M" -- parses as "+6 hours and -3 minutes"
text
- The string to parse and build up to a durationReturns a copy of this duration with the specified duration added.
amountToAdd
- The amount to addunit
- The units to usedaysToAdd
hoursToAdd
millisToAdd
minutesToAdd
nanosToAdd
secondsToAdd
Subtracts this duration to the specified temporal object and return back to you a date/time object
target
- The date/time object or string to subtract the duration fromasInstant
- Return the result either as a date/time string or a java.time.Instant objectGets the number of days in this duration.
Extracts the number of days in the duration.
Gets the number of Hours in this duration.
Extracts the number of HoursPart in this duration.
Gets the number of Millis in this duration.
Extracts the number of MillisPart in this duration.
Gets the number of Minutes in this duration.
Extracts the number of MinutesPart in this duration.
Gets the number of Nanos in this duration.
Extracts the number of NanosPart in this duration.
Gets the number of Seconds in this duration.
Extracts the number of SecondsPart in this duration.
A string representation of this duration using ISO-8601 seconds based representation, such as PT8H6M12.345S.
Returns a copy of this duration with the specified nano-of-second. This returns a duration with the specified nano-of-second, retaining the seconds part of this duration.
nanoOfSecond
- the nano-of-second to represent, from 0 to 999,999,999Returns a copy of this duration with the specified amount of seconds. This returns a duration with the specified seconds, retaining the nano-of-second part of this duration.
seconds
- the seconds to represent, may be negative