You can run your session with a pseudo-clock, advanced to the point in
time that corresponds to your reference date.
KnowledgeSessionConfiguration config =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
config.setOption(ClockTypeOption.get("pseudo"));
StatefulKnowledgeSession session =
knowledgeBase.newStatefulKnowledgeSession(config, null);
SessionPseudoClock clock = session.getSessionClock();
// session clock := NOW
clock.advanceTime( (new java.util.Date()).getTime(), TimeUnit.MILLISECONDS );
// session clock := TOMORROW
clock.advanceTime(1, TimeUnit.DAYS);
This rule would fire, today being the 5-Feb-2013.
rule test
date-effective "6-Feb-2013"
date-expires "7-Feb-2013"
when
$i: Integer()
then
System.out.println( "Integer " + $i );
end
On 05/02/2013, pdario <dario.piantanida(a)gmail.com> wrote:
Hello, I need to have my rules reason with a reference date different
than
today (so I can't use the rule attributes "date-effective",
"date-expires").
I declared a global java.utile.Date, I set it in Java, but I cannot reason
on it...
I don't want to put in each rule a generic Date fact.
What do you suggest to solve this?
Thank you!
--
View this message in context:
http://drools.46999.n3.nabble.com/How-to-pass-a-global-reference-date-to-...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users