Technically, a constant always contains a data type. In the literal expression, we only specify the value. The data type can be inferred from the value (for example string, integer, decimal, etc.). For specific cases such as date time, we use dedicated functions for the representation.
The sections below provide information on the different data type expressions and how they are represented.
string
string
Description
Common sequence of characters. It doesn’t have any specific size except the implicit one that comes from the environment such as the amount of memory available.
JSON format: String
Serialization format: UTF-8
Literal representation
"<value>"
largest positive finite value of type double, (2-2 -52)x2 1023
smallest positive normal value of type double, 2-1022
smallest positive nonzero value of type double, 2 p-1074
dateOnly date-only
Description
Represents a date only without a time zone, viewed as a year-month-day.
It is a description of the date, as used for birthdays.
JSON format: String.
Format is: YYYY-MM-DD (ISO-8601), for example: “2021-03-11”.
It can be encapsulated in a toDateOnly function.
It uses DateTimeFormatter ISO_LOCAL_DATE_TIME to deserialize and serialize the value. Learn more
Literal representation
date("<dateOnly in ISO-8601 format>")
dateTimeOnly date-time-only
Description
Represents a date time without a time zone, viewed as year-month-day-hour-minute-second-millisecond.
JSON format: String.
It does not store or represent a time zone. Instead, it is a description of the date, as used for birthdays, combined with the local time as seen on a wall clock.
It cannot represent an instant on the time-line without additional information such as an offset or time zone.
It can be encapsulated in a toDateTimeOnly function.
Serialization format: ISO-8601 extended offset date-time format.
It uses DateTimeFormatter ISO_LOCAL_DATE_TIME to deserialize and serialize the value. Learn more.
Literal representation
date("<dateTimeOnly in ISO-8601 format>")
dateTime date-time
Description
Date time constant that also considers time zone. It represents a date-time with an offset from UTC.
It can be viewed as an instant in time with the additional information of the offset. It is a way to represent a specific “moment” at a certain place of the world.
JSON format: String.
It can be encapsulated in a toDateTime function.
Serialization format: ISO-8601 extended offset date-time format.
It uses DateTimeFormatter ISO_OFFSET_DATE_TIME to deserialize and serialize the value. Learn more.
You can also pass an integer passing an epoch value. Read more.
Time zone can be specified by an offset or a time zone code (example: Europe/Paris, Z - meaning UTC).
Literal representation
toDateTime("<dateTime in ISO-8601 format>")
duration duration
Description
It represents a time-based amount of time, such as ‘34.5 seconds’. It models a quantity or amount of time in terms of milliseconds.
The supported temporal units are: milliseconds, seconds, minutes, hours, days where a day equals to 24 hours. Years and months are not supported since they’re not a fixed amount of time.
JSON format: String.
It must be encapsulated in a toDuration function.
Serialization format: To deserialize a time zone ID, it uses the java function java.time.
Duration.parse: the formats accepted are based on the ISO-8601 duration format PnDTnHnMn.nS with days considered to be exactly 24 hours. Learn more.
Literal representation
toDuration("<duration in ISO-8601 format>")
list list
Description
Comma separated list of expressions using square brackets as delimiters.
Polymorphism is not supported, hence all the expressions contained in the list should have the same type.
Literal representation
[<expression>, <expression>, ... ]