[rules-users] How to compare java.sql.Dates in a Drools 'when'

Stephen Mcgruer s0840449 at sms.ed.ac.uk
Wed Jul 28 11:23:51 EDT 2010


Hi there,

Sorry for so many questions today. How would one compare dates in a  
Drools when/then rule? I have an object, Tool, that has a last used  
field which is a java.sql.Date (yes, this is a fairly bad type for it  
to be. Long story.). I want to write a rule to check if there is a  
Tool that has this date set in the future. Now, to get the current  
date/time (in Java!) you would do:

java.util.Date today = new java.util.Date();
java.sql.Date sqlToday = new java.sql.Date(today.getTime());

But how do I do something like this in a Drools rule?! (Where I want  
to compare last used to sqlToday).

Thanks,
Stephen

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.





More information about the rules-users mailing list