Skip to main content
Skip table of contents

setDate

Creates a new variable holding a Date value representing a specified date.

Attributes

var

Required

Value type

EL-evaluated

Yes

String

No

Name of the variable that holds the created Date value.

timeZone

Required

Value type

EL-evaluated

No

String

Yes

This attribute can be used to specify a time zone for the created Date 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 Date will use the current user's time zone.

year

Required

Value type

EL-evaluated

No

Number

Yes

Specifies the created Date value's year.

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

month

Required

Value type

EL-evaluated

No

Number

Yes

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

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

day

Required

Value type

EL-evaluated

No

Number

Yes

Specifies the created Date 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 Date represents the current day.

Examples

To create a Date representing the current date, only define the var attribute:

CODE
<setDate var="today">

Using the methods available to Date values, you can create new Dates from any value created with this command. You can, for example, create a Date that's 30 days in the future with the plusDays()method:

CODE
<set var="thirtyDaysAhead" value="${today.plusDays(30)}">

To create a Date representing the current date, but on year 2000, the withYear() method does the job:

CODE
<set var="year2k" value="${today.withYear(2000)}">
JavaScript errors detected

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

If this problem persists, please contact our support.