[rules-users] using homemade Date in Drools

Anstis, Michael (M.) manstis1 at ford.com
Mon May 21 09:55:04 EDT 2007


The simplest way could be to have your Date expose a "Time" type member
(like java.util.Date.getTime()) that represents the number of
seconds\milliseconds etc since a given point in time ("your absolute
zero" for example; being day * month * year * H * M * s * ms). This
could then be used as a simple predicate condition:-

rule XXX
when
    obj1 : A( $time : myTime)
    obj2 : A( myTime < $time )
then
    // something
    obj.doSomething();
End

Thanks,

Mike

-----Original Message-----
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Maxime Catelin
Sent: 21 May 2007 14:34
To: Rules Users List
Subject: [rules-users] using homemade Date in Drools

Hi,

We are using a lot of Dates in our application but we use a homemade 
Date class for that.  Therefore, we cannot use > and < provided by 
Drools.  I looked through the mailing list but could not find any 
examples using Dates in Drools other than in the documentation.  What 
interested me in particular in the documentation was "If more control is

required, use the predicate constraint."

Could someone give some examples of using predicate constraint with
dates?

Something I would like to do, for example, is the following :

If there is an obj1 of class A with field of type Date d1 and another 
obj2 of class A with field Date d2, where d1 is before d2, obj2 should 
be used to fire something.

rule XXX
when
    obj : A( $date : mydate)
    // do not know how to use constraint on date here.
then
    // something
    obj.doSomething();
end

Thanks for your input.
_______________________________________________
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