Drools Date comparison using Java 8 Local Date

Suresh Source

I have a rule that does the pattern matching using Java 8 Local Date. Unfortunately, the comparison does not work with Java 8 Local date but works with old java.util.Date API.

Here is my rule:

 rule "NJ Trauma Rule"
            $bill : MedicalBillData ( treatmentState == "NJ" , lossDate >= "01-JAN-2017" ) // Not OK
//Correct syntax
$bill : MedicalBillData ( treatmentState == "NJ" , 
                                    lossDate.isAfter(LocalDate.of(2017, 7, 1)) )
                //Some actions



public class MedicalBillData
    private LocalDate lossDate;
    private String treatmentState;


Unable to Analyse Expression lossDate >= new java.util.Date(1483250400000): [Error: Comparison operation requires compatible types. Found class java.time.LocalDate and class java.util.Date] [Near : {... lossDate >= new java.util.Date(1483250400000) ....}] ^ : [Rule name='NJ Trauma Rule using Java 8 Date']

Drools version: 7.5.0.Final

Java : 8

Any pointers to solve the issue is appreciated!



comments powered by Disqus