jonathan2260 Posted June 30, 2011 Share Posted June 30, 2011 HelloI'm using iReport 3.51 and I have a report with a parameter $P{Limit}.I use it in a text field as such."Limit of "+ $P{Limit} +" and over"The number I enter in the parameter shows up. So far so good. This is a String class BTW.What I am trying to do now is change the format to be like others text boxes with fields I have on this report that are double classes using a pattern #,##0I tried a few ways such as:"Limit of "+ (new DecimalFormat("#,##0")).format($P{Limit}) +" and over"I keeps getting errors. Does anyone know what I should be entering to get it to work the way I want it? Thanks. Link to comment Share on other sites More sharing options...
cbarlow3 Posted June 30, 2011 Share Posted June 30, 2011 I did some experimenting with a short report where I input a String parameter called $P{InputString}, and here's what I found, using input of 12345678:1. Obviously, if I just output a text field of $P{12345678} as a String field, it outputs: 12345678 with no numerical formatting.2. If I'm not required to combine it with other text, I can use Integer.parseInt($P{InputString})+1 (I incremented just to prove that my output really is an integer) as the Text Field Expression, and then I can set the Expression class to java.lang.Integer manually and I can use the normal "Pattern" button to select the pattern I want ("#,##0", for example), and the result is: 12,345,6793. If I really want the result to be a string that I can then surround with other text, I tried using a Text Field Expression as follows:"The Number+1 is "+(new DecimalFormat("#,##0").format(Integer.parseInt($P{InputString})+1))+", isn't it?"The resulting output looked like this:The Number+1 is 12,345,679, isn't it?So I'm hoping that gives you a few options...method #2 is simpler, but if you really need to embed the number in the midst of text instead of in a field of it's own, you can use method #3 instead.Carl Link to comment Share on other sites More sharing options...
jonathan2260 Posted July 7, 2011 Author Share Posted July 7, 2011 Hi Carl.I ended up using method #3 as it was the best for what I was trying to accomplish. Thanks for the help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now