2017-09-04 30 views
0

ルールの一部に以下の条件を記載する必要があります。ルール日時比較の際のドルロー日付比較

start_date < = end_date + 3 months start_dateとend_dateはDate型のフィールドです。

どうすればいいですか?

+0

可能な複製を(https://でのstackoverflow .com/questions/40781259/how-to-do-date-in-drools) –

+0

私はすでにそれを終えました。私はLHSの部分に3ヶ月を追加する必要がありますが、あなたが言及した質問では、それはRHSの部分で行われています。 – Vijay

+0

上記の質問では、それはLHSで行われます。 LHSは 'when'と' then'の評価部分であり、RHSは 'then'と' end'の間の結果部分です。しかし、あなたの質問に答えることが役に立ちます。 –

答えて

0

まず、非常に奇妙なルールのように感じます。 start_dateは、end_dateの後に、または正確に3か月後に結果が実行されます。

私は次のようにルールがなり、start_dateend_dateがクラスFooのフィールドですと仮定している:[?Droolsの中で日付の計算を行う方法]の

rule "I am checking if the start_date of Foo is more than or exactly three month after the end_date of Foo" 
when 
    Foo($start: start_date, $end: end_date, 
     $end_plus_3_month: DateUtils.addMonths($end, 3), 
     $start.compareTo($end_plus_3_month) <= 0) 
then 
    System.out.printf("The start_date %tD is more that or exactly 3 month after %tD.%n", $start, $end); 
end