Jump to content
We've recently updated our Privacy Statement, available here ×

how to use the Joda dateTime formatter in report (ANSWERED)


tedpet5
Go to solution Solved by tedpet5,

Recommended Posts

I have sucessfully added joda to my classpath and I can display org.joda.time.LocalDate in my report.

I can not seem to figure out how to apply a formatter. I know that the joda formatter looks different than the java flavor.

what is the secret to formatting joda dates whilst in ireport?

 

Ted 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

I was hoping that if the joda .jar was in the classpath, then the datetimeformat would be available.

but no! materialsClose is a joda LocalDate. so its Field Class is org.joda.time.LocalDate.

I tried this as an attempt to have a formatted date, but

(new DateTimeFormat.forPattern("MMMM, yyyy").print($F{materialsClose}))

but the compile error I get is:

DateTimeFormat.forPattern cannot be resolved to a type.

I am importing org.joda.time.DateTime. is there something more I have to import?

Link to comment
Share on other sites

  • 2 weeks later...
  • Solution

I found an answer.

Originally I had a field that was a localdate.   $F{materialsClose}. I was defining its properties/field class to be:  org.joda.time.LocalDate

Instead, I set the field class to java.lang.String

then the "text field expression" for the textField is:  new org.joda.time.LocalDate($F{materialsClose}).toDate()

set the pattern to the format and voila, a properly formatted LocalDate.

Link to comment
Share on other sites

  • 3 years 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...