When working with dates in IBM Tivoli Directory Integrator, this implies using instances of java.util.Date. Armed with any of the available scripting languages, we can implement our own mechanism for handling dates; however, this is not a common practice.
The Directory Integrator scripting engine provides you with a mechanism for parsing dates. The system object has a parseDate(date, format) method accessible at any time.
When you get an instance of java.util.Date, we 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 started from any scripting control point:
var string_date1 = "07.09.1978"; var date1 = system.parseDate(string_date1, "dd.MM.yyyy"); var string_date2 = "1977.02.01"; var date2 = system.parseDate(string_date2, "yyyy.dd.MM"); 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.before() method to determine whether the first date instance comes before the second one. The output of this script is then printed to the log file.
Parent topic: Java + Script ≠ JavaScript