Skip to main content
Skip table of contents

setDateTime

Creates a new variable holding a DateTime value representing a specified date and time.

Attributes

var

Required

Value type

EL-evaluated

Yes

String

No

Name of the variable that holds the created DateTime value.

timeZone

Required

Value type

EL-evaluated

No

String

Yes

This attribute can be used to specify a time zone for the created DateTime value. The resolved String should be a time zone name such as "Europe/London", "America/New_York" or "Etc/GMT+2".

If not defined, the created DateTime will use the current user's time zone.

year

Required

Value type

EL-evaluated

No

Number

Yes

Specifies the created DateTime value's year.

If not defined, the created DateTime represents the current year.

month

Required

Value type

EL-evaluated

No

Number

Yes

Specifies the created DateTime value's month. The resolved value is expected to be an integer from 1 (January) to 12 (December).

If not defined, the created DateTime represents the current month.

day

Required

Value type

EL-evaluated

No

Number

Yes

Specifies the created DateTime value's day. The resolved value is expected be an integer specifying the day within its month, so from 1 to 28, 30 or 31, depending on the month.

If not defined, the created DateTime represents the current day.

hour

Required

Value type

EL-evaluated

No

Number

Yes

Specifies the created DateTime value's hour. The resolved value should be an integer from 0 to 23.

If not defined, the created DateTime represents the current hour.

minute

Required

Value type

EL-evaluated

No

Number

Yes

Specifies the created DateTime value's minute. The resolved value should be an integer from 0 to 59.

If not defined, the created DateTime represents the current minute.

second

Required

Value type

EL-evaluated

No

Number

Yes

Specifies the created DateTime value's second. The resolved value should be an integer from 0 to 59.

If not defined, the created DateTime represents the current second.

Examples

The setDateTime command works exactly like setDate, but with the additional time components. So, to create a DateTime representing the exact moment the command is evaluated, only define the var attribute:

CODE
<setDateTime var="rightNow">

The methods of DateTime values can be used to create more or less altered versions of the base value. To create a DateTime 5 minutes ahead, for example, there is the plusMinutes() method:

CODE
<set var="in5Mins" value="${rightNow.plusMinutes(5)}">
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.