Not sure if it would help, but we have gotten around some Date comparison
problems by using the getTime() method on the Date objects. Basically, it
returns time in ms since 1970 (which works fine for comparison).
I'm not sure if you can create a new Date object in the LHS of the rule. If
you can, that date is set to now. So if you do that, you should be able to
add 2 years in ms (2L * 365L * 24L * 60L * 60L * 1000L) and compare that
with your date.
If you can't create it in the LHS, you could always assert a current data
object to represent the Date either now or 2 years from now.
That being said, couldn't you do something like:
# $todaysDate either from asserted Date object for now, or a new Date()
if can be done
Reference(fromDate.time > ($todaysDate.time - (2L * 365L * 24L * 60L *
60L * 1000L)))
I need to code a rule which checks that the begin date for an object is at
least two years ago (from todays date). Is there an easy way to code this
within Drools rule, something like:
Reference(fromDate > (todaysDate - 2 years))
Thanks in advance,
rules-users mailing list
View this message in context:
Sent from the drools - user mailing list archive at Nabble.com