toDate
Description: Converts a String into a Date data type, based on the format specified by the argument. The argument must be a String that is a valid Java SimpleDateFormat syntax. The Subject is expected to be a String that is formatted according the argument. The date will be evaluated using the local time zone unless specified in the second optional argument.
Subject Type: String
Arguments:
-
format : The current format to use when parsing the Subject, in the Java SimpleDateFormat syntax.
-
time zone : Optional argument that specifies the time zone to use when parsing the Subject, in the Java TimeZone syntax.
Return Type: Date
Examples: If the attribute "year" has the value "2014" and the attribute "time" has the value "2014/12/31 15:36:03.264Z", then the Expression ${year:toDate('yyyy', 'GMT')}
will return a Date data type with a value representing Midnight GMT on January 1, 2014. The Expression ${time:toDate("yyyy/MM/dd HH:mm:ss.SSS'Z'", "GMT")}
will result in a Date data type for 15:36:03.264 GMT on December 31, 2014.
Often, this function is used in conjunction with the format function to change the
format of a date/time. For example, if the attribute "date" has the value "12-24-2014" and
we want to change the format to "2014/12/24", we can do so by chaining together the two
functions: ${date:toDate('MM-dd-yyyy'):format('yyyy/MM/dd')}
.