GlideDate - Global
-
- UpdatedJan 30, 2025
- 8 minutes to read
- Yokohama
- API reference
The GlideDate class provides methods for performing operations on GlideDate objects, such as instantiating GlideDate objects or working with GlideDate fields.
For guidance on date time input strings with a list of common format conflicts, refer to Date and time format guidelines.
See also GlideDateTime - Global.
GlideDate - GlideDate()
Creates a GlideDate object with the current date time.
Name | Type | Description |
---|---|---|
None |
Example
GlideDate - getByFormat(String format)
Gets the date in the specified date format.
Name | Type | Description |
---|---|---|
format | String | Desired date format using Java SimpleDateFormat. For example,
"dd-MM-yyyy" to get the day, month, and year, or
"EEEE" to get the day of the week. |
Type | Description |
---|---|
String | Date value for the GlideDate object in the specified format. |
Example
Scoped equivalent
To use this method in a scoped application, use the corresponding scoped method: Scoped GlideDate - getByFormat(String format).
GlideDate - getDayOfMonthNoTZ()
Gets the day of the month stored by the GlideDate object, expressed in the UTC time zone.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | The day of the month in the UTC time zone, from 1 to 31. |
Example
Output:
Scoped equivalent
To use this method in a scoped application, use the corresponding scoped method: Scoped GlideDate - getMonthNoTZ().
GlideDate - getDisplayValue()
Gets the date in the current user's display format and time zone.
Name | Type | Description |
---|---|---|
none |
Type | Description |
---|---|
String | Date value for the GlideDate object in the current user's display format and time zone. Keep in mind when designing business rules or script includes that this method may return values in different formats for different users. |
Example
Scoped equivalent
To use this method in a scoped application, use the corresponding scoped method: Scoped GlideDate - getDisplayValue().
GlideDate - getDisplayValueInternal()
Gets the date in the internal format (yyyy-MM-dd) and current user's timezone.
Name | Type | Description |
---|---|---|
none |
Type | Description |
---|---|
String | Date value for the GlideDate object in the current user's time zone. Format: yyyy-MM-dd |
Example
Scoped equivalent
To use this method in a scoped application, use the corresponding scoped method: Scoped GlideDate - getDisplayValueInternal().
GlideDate - getDisplayValueLang(String style)
Returns the date value in the user's locale according to a specified date style.
Name | Type | Description |
---|---|---|
style | String | Date format. Valid values:
If any other value is passed the API defaults to |
Type | Description |
---|---|
String | A string representation of the date in the style specified and in the appropriate format for the locale of the current user. |
Example
The following example returns the date of the user's locale in all styles.
Output:
GlideDate - getDisplayValueLang(String style, String language)
Returns the date value in the user's locale and language according to a specified date style.
Name | Type | Description |
---|---|---|
style | String | Date format. Valid values:
If any other value is passed the API defaults to
|
language | String | Returns the date according to a specified language value. Accepts language tags
that conform with the BCP-47 standard. For example, fr for French
or en-UK for British English. For a full list of accepted values,
see BCP 47 Language Code List. |
Type | Description |
---|---|
String | Date in the style and language specified according to the locale of the current user. |
Example
The following example returns the date of the user's locale in various languages and styles.
Output:
GlideDate - getMonthNoTZ()
Gets the month stored by the GlideDate object, expressed in the UTC time zone.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | The numerical value of the month from 1 to 12. |
Example
Output:
Scoped equivalent
To use this method in a scoped application, use the corresponding scoped method: Scoped GlideDate - getMonthNoTZ().
GlideDate - getYearNoTZ()
Gets the year stored by the GlideDate object, expressed in the UTC time zone.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Number | The numerical value of the year. |
Example
Output:
Scoped equivalent
To use this method in a scoped application, use the corresponding scoped method: Scoped GlideDate - getYearNoTZ().
GlideDate - parseDate(String date, String language, String country)
Parses a date to the locale associated with the passed language and country codes.
Name | Type | Description |
---|---|---|
date | String | Date formatted in regional syntax. Formats:
|
language | String | ISO-639 two-character language code. |
country | String | ISO-3166 two-character country code. |
Type | Description |
---|---|
Object | Parsed GlideDate object that you can use in calculations or insert in a record. This method throws an exception if the date failed to parse. An exception happens when the date format doesn't match the specified locale format (passed language and country parameters). |
Example
The following code example parses a date and adds four weeks to that date.
Output:
GlideDate - setDisplayValue(String asDisplayed)
Sets a date value using the current user's display format and time zone.
Name | Type | Description |
---|---|---|
asDisplayed | String | Date in the current user's display format and time zone. Format: Must be formatted using the current user's preferred display format, such as yyyy-MM-dd. |
Type | Description |
---|---|
None |
Example
Output:
Scoped equivalent
To use this method in a scoped application, use the corresponding scoped method: Scoped GlideDate - setDisplayValue(String asDisplayed).
GlideDate - setDisplayValueLang(String date, String style)
Sets a date using a specified style and format according to the current user's locale.
Name | Type | Description |
---|---|---|
date | String | Date value for the GlideDate object in the current user's time zone. Valid
values are any date and time output from the
getDisplayValueLang() function. For instance, using output from the getDisplayValueLang(String style, String language) example earlier in this topic, October 25, 2022 or 25.10.2022 are accepted values. |
style | String | Date format. Valid values:
If any other value is passed the API defaults to
|
Type | Description |
---|---|
void |
Example
The following example shows how you can set the current date of the user's locale to 'full' style using setDisplayValueLang().
Output:
GlideDate - setDisplayValueLang(String date, String style, String language)
Sets a date using a specified style, language, and format according to the current user's locale.
Name | Type | Description |
---|---|---|
date | String | Date value for the GlideDate object in the current user's time zone. Valid
values are any date and time output from the
getDisplayValueLang() function. For instance, using output from the getDisplayValueLang(String style, String language) example earlier in this topic, October 25, 2022 or 25.10.2022 are accepted values. |
style | String | Date format. Valid values:
If any other value is passed the API defaults to
|
language | String | Sets the language using a language tag that conforms with the BCP-47 standard.
For example, fr for French or en-UK for British
English. For a full list of accepted values, see BCP 47 Language Code List. |
Type | Description |
---|---|
Void |
Example
The following example returns the date and time in short and full styles for English and French.
Output:
GlideDate - setValue(String o)
Sets the date of the current GlideDate object in internal format (yyyy-MM-dd) and the system time zone (UTC by default).
Name | Type | Description |
---|---|---|
o | String | Date and time to set in the current GlideDate object. Format: yyyy-MM-dd |
Type | Description |
---|---|
None |
Example
Output:
Scoped equivalent
To use this method in a scoped application, use the corresponding scoped method: Scoped GlideDate - setValue(String o).
On this page
- GlideDate - GlideDate()
- GlideDate - getByFormat(String format)
- GlideDate - getDayOfMonthNoTZ()
- GlideDate - getDisplayValue()
- GlideDate - getDisplayValueInternal()
- GlideDate - getDisplayValueLang(String style)
- GlideDate - getDisplayValueLang(String style, String language)
- GlideDate - getMonthNoTZ()
- GlideDate - getYearNoTZ()
- GlideDate - parseDate(String date, String language, String country)
- GlideDate - setDisplayValue(String asDisplayed)
- GlideDate - setDisplayValueLang(String date, String style)
- GlideDate - setDisplayValueLang(String date, String style, String language)
- GlideDate - setValue(String o)