Not a bug.
DateTime is a complicated type and complicated types rarely work with ==
. Try
if(dt1.equals(dt2))
It’s a long explanation which I won’t go into here. Suffice to say it is what many consider to be a design flaw in Java and therefore a design flaw inherited by the Rules DSL which runs on Java.
For a rule of thumb, you can only use ==
for:
- Number
- BigDecimal
- primitives
- Strings
- Boolean
- Enums (e.g ON, OFF, OPEN, CLOSED)
All other types such as DateTime must either be converted to one of the above to use ==
or you must use the .equals
method instead.
As to the logInfo statement, @watou provided a way to call logInfo that has the smarts to figure out how to extract the String representation of dt1 and dt2.
I suspect the following would have worked as well:
logInfo("TestNow", dt1.toString)