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

DateFormatUtils in crosstab problem


scottward

Recommended Posts

Hello,

 

When I place a text field with the following expression in the main report, everything works fine:

"test " + org.apache.commons.lang.time.DateFormatUtils.format($V{StartDate}, "yyyy")

 

When I place the same expression in a textfield in the detail field of a crosstab, I get the following error:

 

Error evaluating expression : Source text : "test " + org.apache.commons.lang.time.DateFormatUtils.format($V{StartDate}, "yyyy")
groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method: format. Cannot resolve which method to invoke due to overlapping prototypes between: [long, class java.lang.String] and: [class java.util.Date, class java.lang.String] at groovy.lang.MetaClass.checkForInvalidOverloading(MetaClass.java:1770)

 

The StartDate measure is set as a Date with an expression that references the StartDate parameter, which is a Date.

 

This is interesting: when I replace $V{StartDate} with "new Date()" it works fine! Also, if I type in numbers (to pretend that I want to enter a Long) it compiles.

 

Its like the compiler can't tell if $V{StartDate} is a Date or a Long. But again I've triple checked that indeed it is a Date!

 

What am I missing here? It may be something simple that my non-Java-experiened-eyes can't see.

 

You're input is greatly appreciated.

 

Scotty

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Thanks for the response Lucian.

 

I figured out that the problem had to do with the the fact that whenever the measure was null, so was the variable I was passing to DateFormatUtils. The text field had an expression set to a measure and a hypertextReference that utilized a parameter to construct the link. When the measure was null, the paramater was too for some reason.

 

I just made the expression for the link conditional so it only constructed the link (and referenced DateFormatUtils) if the measure was not null.

 

Scotty

Link to comment
Share on other sites

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...