user3427542
user3427542

Reputation: 99

Jasper Report Generation Date

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

Answers (4)

Philip Appiah
Philip Appiah

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"/>
<textFieldExpression><![CDATA["Report Generated on: "+new java.util.Date()]]></textFieldExpression> </textField>
The 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:50for the 24 hour format.

Upvotes: 0

Nitin Gaur
Nitin Gaur

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

Happy Dhingra
Happy Dhingra

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

Zoran Stipanicev
Zoran Stipanicev

Reputation: 522

Open Palette (Window->Palette) and drag "Current date" from "Tools" section to your report.

Upvotes: 2

Related Questions