Jump to content

Display multiple values in one field


synchro

Recommended Posts

I want to format two or more variables into a single text field. I've made this work by having this as a text expression:

new java.lang.String().concat($P{EnterStartingDate}.toString()).concat(" to ").concat($P{EnterEndDate}.toString())

the two vars are dates, so it comes out like this:

Sun Jan 01 00:00:00 GMT 2012 to Sun Jan 29 00:00:00 GMT 2012

Both the code and the result are horribly ugly!

So,

a) is there a nicer mechanism for embedding multiple variables in a single output string?

b) is there a date formatting method? Something like $P{EnterStartingDate}.dateFormat("y-M-d") would be ideal.

Is there a straightforward reference guide for iReports? I've seen there is a paid-for user guide, but I'm not really after a user guide, just a reference.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I don't think there's a free reference for iReport.  On the plus side, that helps keep this forum pretty active! :)  I started keeping my own personal documentation that's a mix of my personal experience and good answers I've gotten on this forum, and I've documented that when I want to do my own date formatting (usually for the same reason you cited: so I can combine it with other string data in a single field), I do this:

new StringBuilder(new SimpleDateFormat("yyyy-MM-dd").format($P{EnterStartingDate}))+" to " + new StringBuilder(new SimpleDateFormat("yyyy-MM-dd").format($P{EnterEndDate}))

Hope that helps.

Carl

 P.S.:  you can also use "MM/dd/yyyy" (or other variations) instead of "yyyy-MM-dd", if you're so inclined.  Look up SimpleDateFormat in Java documentation to get all the options.



Post Edited by cbarlow3 at 01/31/2012 18:01
Link to comment
Share on other sites

  • 2 weeks 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...