[rules-users] Date for 2 years ago

Dean Jones dean.m.jones at gmail.com
Tue Sep 18 05:12:39 EDT 2007


Hello Brian,

I've done something similar previously using a combination of a field
binding constraint, an eval and the excellent joda-time API
(http://joda-time.sourceforge.net/). If I remember right, you'd need
something along the lines of :

import org.joda.time.Duration;
import org.joda.time.DateTime;

Reference($fromDate : fromDate, eval(new Duration(new
DateTime($fromDate), new DateTime()).getMillis() >
(2*365*24*60*60*1000)))

It might be more readable if you can encapsulate this in a function :-)

Dean.


On 9/18/07, Brian Enderle <brianke at gmail.com> wrote:
> 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:
>
> when
>    Reference(fromDate > (todaysDate - 2 years))
> then
>    <Output error>
> end
>
> Thanks in advance,
> Brian Enderle
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list