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
Inherited Variables
Function Summary
- public add(other: Duration) : Duration
- public div(n: Number) : Duration
- public div(other: Duration) : Number
- 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
- 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. This function does not change the value of called Duration instance.-
Returns
- Duration
Profile: common
- public sub(other: Duration) : Duration
- public toDate() : java.util.Date
- public toHours() : Number
- public toMillis() : Number
- public toMinutes() : Number
- public toSeconds() : Number
- 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