Check whether given time is existing between two time parameters in drools

431 views Asked by At

I have the value like starttime(8.30 am) to endtime(5.00pm) .I need to check that whether current time is between the stattime and endtime.

rule "rule1"

   when 

     day="Monday" && currentTime between (8.45am) and (5.00pm) ; 

   then

     return true;

  when 

    day="Sunday" && currentTime between (9.00am) and (11.00am); 

  Then

    return true;

End

1

There are 1 answers

0
laune On

Insert an object of a simple class TimeOfWeek with the day of the week and the current time of the day. Then you may

TimeOfWeek( wday == "Monday", tod >= 945 && tod <= 1700 )

@J Andy: Fusion and the temporal operators deal with events, timestamped with absolute time values. That's not what OPs constraints appear to need.