Example 2—Function
Functions are used for more complex elements and are written in Java. In this example, the function is used to compare dates. It would be configured as follows:
Name: compareDates Description: This function is required to compare dates. Implementation: import java.util.Date; import java.text.SimpleDateFormat; function int _GRS_compareDate(String a, String b) { // Compare two dates and returns: // -99 : invalid/bogus input // -1 : if a < b // 0 : if a = b // 1 : if a > b SimpleDateFormat dtFormat = new SimpleDateFormat(“dd-MMM-yyyy”); try { Date dt1= dtFormat.parse(a); Date dt2= dtFormat.parse(b); return dt1.compareTo(dt2); } catch (Exception e) { return -99; } }
For user-supplied classes, the .jar file must be in the CLASSPATH for both the GRAT and the GRE.
The figure below shows how this function would appear in the Genesys Rules Development Tool.
This page was last edited on September 19, 2016, at 17:48.
Comments or questions about this documentation? Contact us for support!