Overview
A class that defines a duration of time. Duration instances are defined in
milliseconds, but can be easily created using time literals; for
example, a two-and-a-half minute Duration instance can be defined in several
ways:
Duration instances are immutable, and are therefore replaced rather than modified.
To create a new Duration instance, either use a time literal, or use the
Duration t = 2m + 30s;
Duration t = 2.5m;
Duration t = 2500ms;
Duration.valueOf(milliseconds)
factory method.
Profile: common
Script Variable Summary
access | name | type | Can Read | Can Init | Can Write | Default Value | description |
---|---|---|---|---|---|---|---|
public | INDEFINITE | Duration | |||||
public | ONE | Duration | |||||
public | TYPE_INFO | TypeInfo | |||||
public | ZERO | Duration |
Used to specify a duration of indefinite length. |
Inherited Variables
Script Function Summary
- public valueOf(ms: Double) : Duration
-
Factory method that returns a Duration instance for a specified number of milliseconds.
Factory method that returns a Duration instance for a specified number of milliseconds.
-
Parameters
- ms
- the number of milliseconds
-
Returns
- Duration
- a Duration instance of the specified number of milliseconds
Profile: common
- public valueOf(ms: Number) : Duration
Function Summary
- public add(other: Duration) : Duration
-
Add this instance and another Duration instance to return a new Duration instance.
Add this instance and another Duration instance to return a new Duration instance. If either instance is INDEFINITE, return INDEFINITE. This function does not change the value of the called Duration instance.
-
Parameters
- other
-
Returns
- Duration
Profile: common
- compareTo(obj: java.lang.Object) : Integer
- public div(n: Number) : Duration
-
Divide this instance by a number to return a new Duration instance.
Divide this instance by a number to return a new Duration instance. If the called Duration instance is INDEFINITE, return INDEFINITE. This function does not change the value of the called Duration instance.
-
Parameters
- n
-
Returns
- Duration
Profile: common
- public div(other: Duration) : Number
-
Divide this instance by another Duration to return the ratio.
Divide this instance by another Duration to return the ratio. If both instances are INDEFINITE, return NaN. If this instance is INDEFINITE, return POSITIVE_INFINITY If the other instance is INDEFINITE, return 0.0. This function does not change the value of the called Duration instance.
-
Parameters
- other
-
Returns
- Number
Profile: common
- public ge(other: Duration) : Boolean
- public gt(other: Duration) : Boolean
- public le(other: Duration) : Boolean
- public lt(other: Duration) : Boolean
- public mul(n: Number) : Duration
-
Multiply this instance with a number to return a new Duration instance.
Multiply this instance with a number to return a new Duration instance. If the called Duration instance is INDEFINITE, return INDEFINITE. This function does not change the value of the called Duration instance.
-
Parameters
- n
-
Returns
- Duration
Profile: common
- public negate() : Duration
-
Return a new Duration instance which has a negative number of milliseconds from this instance.
Return a new Duration instance which has a negative number of milliseconds from this instance. For example,
(50ms).negate()
returns a Duration of -50 milliseconds. If the called Duration instance is INDEFINITE, return INDEFINITE. This function does not change the value of the called Duration instance.-
Returns
- Duration
Profile: common
- public sub(other: Duration) : Duration
-
Subtract other Duration instance from this instance to return a new Duration instance.
Subtract other Duration instance from this instance to return a new Duration instance. If either instance is INDEFINITE, return INDEFINITE. This function does not change the value of the called Duration instance.
-
Parameters
- other
-
Returns
- Duration
Profile: common
- public toHours() : Number
- public toMillis() : Double
- public toMinutes() : Number
- public toSeconds() : Number