Jump to content
Changes to the Jaspersoft community edition download ×

Display current date in report


2004 IR Help

Recommended Posts

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

  • 10 years later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • 7 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...