Date formatting part of text in Jasper / ireports

Meeza S picture Meeza S · Apr 4, 2013 · Viewed 55.8k times · Source

how do I format a date field (database field) displayed part of a text in Jasper / iReports (4.5.1)

Displayed via a text field in the report... (using Groovy please)

"Sub total for this date: " + $F(DEPOSIT_DATE)

I have tried (new SimpleDateFormat("MM/dd/yyyy")).parse($F{DEPOSIT_DATE})and I am getting error message:

net.sf.jasperreports.engine.fill.JRExpressionEvalException: 
Error evaluating expression : Source text : (new SimpleDateFormat("MM/dd/yyyy")).parse($F{BANK_DATE}) 

What I want to display in my report is as follows...

Sub total for this date: MM/DD/YYYY - format...

Answer

Meeza S picture Meeza S · Apr 4, 2013

Try this:

new SimpleDateFormat("MM/dd/yyyy").format($F{BANK_DATE})