toDate
Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center? Click here !
Availability
This routine is available starting with SIL Engine™ 2.5.5.
Syntax
toDate(year, month, day[, hour, minute, second[, millis]])
Starting with katl-commons 2.5.6:
toDate(year, month, day[, hour, minute, second[, millis[, timeZone]]])
Description
Creates a date value from the specified parameters.Parameters
Parameter name | Type | Required | Restrictions | Description |
---|---|---|---|---|
year | number | Yes | - | Specifies the year value. |
month | number | Yes | [1-12] | Specifies the month value. This value is 1-based (e.g 1 = January, 12 = December). |
day | number | Yes | [1-28-29-30-31] | Specifies the day of month value. Providing an invalid day value for the specified month/year (e.g. 30 Feb 2013, 29 Feb 2013) will throw an exception at runtime. |
hour | number | No | [0-23] | Specifies the hour of day value. |
minute | number | No | [0-59] | Specifies the minutes value. |
second | number | No | [0-59] | Specifies the number of seconds. |
millis | number | No | [0-999] | Specifies the number of milliseconds. |
timeZone | string | No | - | Specifies the time zone using a format compatible with TimeZone. See TimeZone for more details. |
Wrong parameters
If any of the parameters are outside of the specified interval (e.g attempting to create 32 January), the routine will return an empty date, such that isNull(date) is "true".
Note
The created date will use the locale of the JVM.
Return type
date
Example
function toDate7Descr(number year, number month, number day, number hour, number minute, number second, string timeZone) { string format = "dd-MMM-yyyy HH:mm:ss Z"; desc += "Converted year " + year + ", month " + month + ", day " + day + ", hour " + hour + ", minute " + minute + ", second " + second + ", timeZone " + timeZone; desc += " to date " + formatDate(toDate(year, month, day, hour, minute, second, 0, timeZone), format) + "\n"; } function toDate6Descr(number year, number month, number day, number hour, number minute, number second){ desc += "Converted year " + year + ", month " + month + ", day " + day + ", hour " + hour + ", minute " + minute + ", second " + second; desc += " to date " + toDate(year, month, day, hour, minute, second) + "\n"; } function toDate3Descr(number year, number month, number day){ desc += "Converted year " + year + ", month " + month + ", day " + day; desc += " to date " + toDate(year, month, day) + "\n"; } desc = ""; toDate3Descr(2013, 12, 31); toDate3Descr(2013, 2, 28); toDate3Descr(2012, 2, 29); toDate3Descr(2013, 2, 29); toDate6Descr(2013, 12, 31, 23, 59, 59); toDate6Descr(2013, 2, 28, 0, 0, 0); toDate6Descr(2012, 2, 29, 14, 15, 16); toDate6Descr(2013, 1, 1, 24, 1, 1); toDate7Descr(2012, 01, 20, 0, 0, 0, "GMT+2");
Outputs to description:
Converted year 2013, month 12, day 31 to date 2013-12-31 00:00:00
Converted year 2013, month 2, day 28 to date 2013-02-28 00:00:00
Converted year 2012, month 2, day 29 to date 2012-02-29 00:00:00
Converted year 2013, month 2, day 29 to date
Converted year 2013, month 12, day 31, hour 23, minute 59, second 59 to date 2013-12-31 23:59:59
Converted year 2013, month 2, day 28, hour 0, minute 0, second 0 to date 2013-02-28 00:00:00
Converted year 2012, month 2, day 29, hour 14, minute 15, second 16 to date 2012-02-29 14:15:16
Converted year 2013, month 1, day 1, hour 24, minute 1, second 1 to date
Converted year 2012, month 1, day 20, hour 0, minute 0, second 0, timeZone GMT+2 to date 20-Jan-2012 00:00:00 +0200
See also