如何比较jrxml文件中jasper报告的当前日期?

问题描述:

我想将日期与当前日期进行比较,但我没有得到如何在jrxml中表示当前日期。
代码是这样的

I want to compare date with current date but I am not getting how to represent current date in jrxml. Code is something like this

<textFieldExpression class="java.lang.String">
    <![CDATA[ $F{dueDate} > [new java.util.Date()] ? "some value" : "some other value" ]]>
</textFieldExpression>

您能告诉我这段代码的正确表示吗?

Can you please tell me correct representation of this code?

尝试在 java.util.Date中使用 before()方法比较两个日期时code>类。以下示例适用于我:

Try using the before() method in the java.util.Date class when comparing the two dates. The following example worked for me:

<textFieldExpression class="java.lang.String"><![CDATA[($P{date1}).before(new java.util.Date()) ? "aaa" : "bbb"]]></textFieldExpression>

如果你想检查新Date()获得的值,你可以将它放入textfield并在报告中的某处打印。

If you want to check the value you get for new Date(), you can put it in a textfield and print it somewhere in your report.