1
votes

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.

4
Your question is not clear, anyway to show the date you can use simple static text, and if you want to print through parameter you can create a parameter and give a default date in this format -- new Date(114,02,31) for date 31-March-2014.Sharad

4 Answers

2
votes

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

0
votes

You can take a static field and then create instance of the Date class as new Date() to print current date in desired pattern.

0
votes

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>
0
votes

<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.