如何比较jrxml文件中jasper报告的当前日期? [英] How do I compare current date in jrxml file for jasper reports?

查看:134
本文介绍了如何比较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()方法类。以下示例适用于我:

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.

这篇关于如何比较jrxml文件中jasper报告的当前日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆