2004 IR Help Posted August 22, 2006 Share Posted August 22, 2006 By: Alan Shiers - ashiers Display current date in report 2005-05-28 11:41 Hi there, I've been trying to figure out how to display the current date in my report. I declared a variable of type Date and later call on the variable in a textfield object, as you can see below. It's not working. I keep getting NullPointerExceptions. Can someone please explain where it is I've gone wrong? Thanks, Alan ... <variable name="Today" class="java.util.Date" calculation="System"> <variableExpression><![CDATA[new Date()]]></variableExpression> </variable> ... <textField> <reportElement positionType="Float" isPrintRepeatedValues="false" x="105" y="110" width="66" height="20"/> <textElement> <font fontName="sansserif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[new SimpleDateFormat("yyyy/MM/dd")).format($V{Today})]]></textFieldExpression> </textField> By: jorge - sirion_oef RE: Display current date in report 2005-05-28 16:52 you could pass the date like a parameter to your report By: John Zoetebier - johnzoet RE: Display current date in report 2005-07-19 22:24 I got it working like this: => <variable name="Today" class="java.lang.String" resetType="Report" calculation="Nothing"> <variableExpression><![CDATA[(new SimpleDateFormat("yyyy/MM/dd")).format(new Date())]]></variableExpression> </variable> ... <textFieldExpression class="java.lang.String"><![CDATA[$V{Today}]]></textFieldExpression> </textField> => Link to comment Share on other sites More sharing options...
shanusingh20000 Posted February 2, 2017 Share Posted February 2, 2017 IN Default value expression set : new Date() Link to comment Share on other sites More sharing options...
luke.brogan Posted September 11, 2017 Share Posted September 11, 2017 Hello, Check this post, it will help:https://community.jaspersoft.com/blog/dates-jasper-ireport-or-jasper-studio Cheers,Luke. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now