|
|
Using date values in scriptingWhen we talk about using dates, we are referring to instances of java.util.Date. Armed with any of the available scripting languages you can of course implement your own mechanism for handling dates. This will not, however, be a common practice. The MI scripting engine provides you with a mechanism for parsing dates. The system object has a parseDate(date, format) method accessible at any time. The specification for this method is available here. Note that once you get an instance of java.util.Date , you can use the standard java libraries and classes to extend your processing. Here is a simple JavaScript example that handles dates. This code can be placed and executed from any scripting control point: var string_date1 =
"07.09.1978"; var string_date2 =
"1977.02.01"; task.logmsg(date1 + " is before " + date2 + ": " + date1.before(date2)); The script code first parses two date values (in different formats) into java.util.Date. It then uses the standard java.util.Date method "before(java.util.Date)" to determine whether the first date instance comes before the second one. The output of this script is then printed to the log file.
|
![]() |
|