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"
        when
            $bill : MedicalBillData ( treatmentState == "NJ" , lossDate >= "01-JAN-2017" ) // Not OK
//Correct syntax
$bill : MedicalBillData ( treatmentState == "NJ" , 
                                    lossDate.isAfter(LocalDate.of(2017, 7, 1)) )
            then 
                //Some actions

    end

//POJO

public class MedicalBillData
  {
    private LocalDate lossDate;
    private String treatmentState;
   }

Error:

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!

java-8droolslocaldate

Answers

comments powered by Disqus