GlideDuration - Scoped
-
- UpdatedJan 30, 2025
- 3 minutes to read
- Yokohama
- API reference
The GlideDuration class provides methods for working with spans of time known as durations.
GlideDuration objects store the duration as the number of days and time from January 1, 1970, 00:00:00. As a result, the setValue() and getValue() methods use the scoped GlideDateTime object for parameters and return values.
GlideDuration - GlideDuration()
Instantiates a GlideDuration object.
Name | Type | Description |
---|---|---|
None |
GlideDuration - GlideDuration(GlideDuration another)
Instantiates a GlideDuration object by cloning the values of the passed in GlideDuration object.
Name | Type | Description |
---|---|---|
another | GlideDuration | GlideDuration object. |
Example
Output:
GlideDuration - GlideDuration(Number milliseconds)
Instantiates a GlideDuration object with the specified duration in milliseconds.
Name | Type | Description |
---|---|---|
milliseconds | Number | Duration value. Unit: Milliseconds |
Example
Output:
GlideDuration - GlideDuration(String displayValue)
Instantiates a GlideDuration object with the specified duration display value.
Name | Type | Description |
---|---|---|
displayValue | String | Duration value. Format: d HH:mm:ss where "d" is number of days. |
Example
Output:
GlideDuration - add(GlideDuration duration)
Adds the duration of the specified GlideDuration object to the current GlideDuration object.
Name | Type | Description |
---|---|---|
duration | GlideDuration | GlideDuration object that contains the duration value to add to the current GlideDuration object. |
Type | Description |
---|---|
GlideDuration | New GlideDuration object whose duration is the sum of the durations of the two GlideDuration objects. |
Example
Output:
GlideDuration - getByFormat(String format)
Returns the duration value in the specified format.
Name | Type | Description |
---|---|---|
format | String | Duration format. |
Type | Description |
---|---|
String | Current duration in the specified format. |
Example
Output
GlideDuration - getDayPart()
Returns the number of days.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | Number of days in the duration. |
Example
Output:
Scoped GlideDuration - getDisplayValue()
Returns the display value of the duration in number of days, hours, and minutes.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Number of days, hours, and minutes, such as 2 Days 10 Hours 36
Minutes. Format: Display value: "n" Days "n" Hours "n" Minutes |
Example
Output:
GlideDuration - getDurationValue()
Returns the duration value in "d HH:mm:ss" format.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Duration value. Format: d HH:mm:ss where "d" is number of days. |
Example
Output:
GlideDuration - getRoundedDayPart()
Returns the rounded number of days. If the time part is more than 12 hours, the return value is rounded up. Otherwise, it is rounded down.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | Day value of the display value rounded. |
Example
Output:
GlideDuration - getValue()
Returns the internal date/time value of the current GlideDuration object.
GlideDuration objects store the duration as a date and time from January 1, 1970, 00:00:00.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Current duration within the GlideDuration object. Format: YYYY-MM-DD HH:mm:ss |
Example
GlideDuration - setDisplayValue(String asDisplayed)
Sets the duration display value.
Name | Type | Description |
---|---|---|
asDisplayed | String | Display duration value to set. Format: d HH:mm:ss where "d" is number of days |
Type | Description |
---|---|
None |
Example
Output:
GlideDuration - setValue(Object o)
Sets the internal date/time value of the GlideDuration object.
The method sets the duration value to the difference of the passed in date/time the base date/time value of January 1, 1970, 00:00:00. The passed in date/time object (string) is parsed into a GlideDateTime object.
Name | Type | Description |
---|---|---|
o | Object | Date and time to use as the endpoint for the calculated duration time.
Format: YYYY-MM-DD HH:mm:ss |
Type | Description |
---|---|
None |
Example
GlideDuration - subtract(GlideDuration duration)
Subtracts the duration of the specified GlideDuration object to the current GlideDuration object.
Name | Type | Description |
---|---|---|
duration | GlideDuration | GlideDuration object that contains the duration value to subtract from the current GlideDuration object. |
Type | Description |
---|---|
GlideDuration | New GlideDuration object whose duration contains the result of the subtraction of the duration of the two GlideDuration objects. |
Example
On this page
- GlideDuration - GlideDuration()
- GlideDuration - GlideDuration(GlideDuration another)
- GlideDuration - GlideDuration(Number milliseconds)
- GlideDuration - GlideDuration(String displayValue)
- GlideDuration - add(GlideDuration duration)
- GlideDuration - getByFormat(String format)
- GlideDuration - getDayPart()
- Scoped GlideDuration - getDisplayValue()
- GlideDuration - getDurationValue()
- GlideDuration - getRoundedDayPart()
- GlideDuration - getValue()
- GlideDuration - setDisplayValue(String asDisplayed)
- GlideDuration - setValue(Object o)
- GlideDuration - subtract(GlideDuration duration)