【问题标题】:Drools date comparision when part of the rule当规则的一部分时流口水日期比较
【发布时间】:2017-09-04 10:59:26
【问题描述】:

我需要在规则的一部分中写下以下条件。

开始日期

谁能告诉我该怎么做?

【问题讨论】:

  • 我已经经历过了。我需要在 LHS 部分添加 3 个月,而在您提到的问题中,它是在 RHS 部分完成的。
  • 不。在提到的问题中,它是在 LHS 中完成的。 LHS是whenthen之间的评估部分,RHS是thenend之间的结果部分。但是,如果这有帮助,我会回答你的问题。

标签: java drools-guvnor


【解决方案1】:

首先,这感觉像是一个非常奇怪的规则。当start_date 晚于或恰好在end_date 三个月后执行结果。

我假设start_dateend_dateFoo 类的字段,规则如下:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-06
    • 2017-11-08
    • 2016-04-16
    • 1970-01-01
    • 2011-12-02
    • 1970-01-01
    • 2011-02-11
    • 2019-09-26
    相关资源
    最近更新 更多