Reputation: 99
I'm creating jasper report and want to print the report generation date(current) on the report? How do I do that with ireport? I hope you can help me.
Upvotes: 1
Views: 10965
Reputation: 1
<textField pattern="**dd-MMM-yyyy hh:mm**">
<reportElement x="0" y="1" width="280" height="21" isRemoveLineWhenBlank="true" uuid="3f452153-41b0-4296-84b9-5a78825a18dc"/>
<textElement verticalAlignment="Middle"/>
The
<textFieldExpression><![CDATA["Report Generated on: "+new java.util.Date()]]></textFieldExpression>
</textField>new java.util.Date()
allows your to format date in a more clean way and precise.The pattern i have specified above will print 26-Oct-2017 17:50
for the 24 hour format.
Upvotes: 0
Reputation: 122
Use the following in your jrxml...Cheers! Screenshot
<textField pattern="MMM d, yyyy h:mm:ss a z">
<reportElement x="0" y="1" width="280" height="21" isRemoveLineWhenBlank="true" uuid="3f452153-41b0-4296-84b9-5a78825a18dc"/>
<textElement verticalAlignment="Middle">
<font isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["Report Generated on: "+new java.util.Date()]]></textFieldExpression>
</textField>
Upvotes: 0
Reputation: 21
You can take a static field and then create instance of the Date class as new Date() to print current date in desired pattern.
Upvotes: 0
Reputation: 522
Open Palette (Window->Palette) and drag "Current date" from "Tools" section to your report.
Upvotes: 2