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

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 

tedpet5's picture
89
Joined: May 5 2012 - 1:24am
Last seen: 1 year 4 months ago

When you checked a post to show it's been resolved, nobody else can't post an answer.

hozawa - 7 years 1 week ago

2 Answers:

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.

tedpet5's picture
89
Joined: May 5 2012 - 1:24am
Last seen: 1 year 4 months ago

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?

tedpet5's picture
89
Joined: May 5 2012 - 1:24am
Last seen: 1 year 4 months ago

someone must know about Joda and iReports!!!!

tedpet5 - 10 years 1 month ago
Feedback