If it a java.util.Date then drools supports comparing them out of the box so you can just do subObjcet.dateField >= now.
Just make sure you don't mix up instances of java.util.Date and java.sql.Timestamp (eg if you have jpa code fetching object from the db) as sun in their wisdom made it that you can't compare them with each other! Thomas > -----Original Message----- > From: [email protected] [mailto:rules-users- > [email protected]] On Behalf Of Slorg1 > Sent: 23 September 2011 13:54 > To: [email protected] > Subject: Re: [rules-users] Issue using global 'variable' with Drools 5.2 in > DRL > > Hi Wolfgang, > > Thank you for answering, here is the rule rewritten but closer to reality: > > // package > > // imports > > global java.util.Date now; > > rule "MyRule" > salience 5 > when > // Prevent rule activation for other offer types. > MyObject(type == Type.TYPE_SOUGHT) > > $candidate : Candidate( > subObject.dateField != null && subObject.dateField.time >= > now.time) > then > // do something > end > > A value for 'now' being set like so: > session.setGlobal("now", new Date()); // Date being the java.util.Date. > > But I do not think that matters because 'compilation' fails at this point. > > Thank you in advance for your time. > > -- > View this message in context: http://drools.46999.n3.nabble.com/Issue- > using-global-variable-with-Drools-5-2-in-DRL-tp3360343p3361770.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users ************************************************************************************** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the [email protected] and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ************************************************************************************** _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
