Hi Everyone,
I have a variable expression that is a java.math.BigDecimal expression class and is defined as follows:
new java.math.BigDecimal($F{loan_amount}.intValue()/100
When I place this variable into my report, I can assign a currency pattern to the variable without issue. However, I would like to combine this varaible into a sentence so that it reads "Your loan amount is equal to $xx,xxxx".
When I attempt to simply add the text to the text field (i.e. "Your loan amount is equal to "+$V{OrigLoanBal}, I receive an error when IReport attempts to evaluate the expression.
I believe that I need to convert the BigDecimal to a string but unfortunately don't know Java at all (have been learning through osmosis on this forum) and can't find any similar statements if I were to try to use Groovy. Does anyone have any thoughts?
Second - can anyone recommend a good book or web site that shows examples of java expressions or groovy expressions. I have the Definitive Guide to IReport which has proved helpful on many items - but it unfortunately assumes that the reader has a good knowledge of Java. I've read countless sites that discuss java programming, but most of those seem to be overkill for what I'm looking for. Any thoughts?
Thank you [again] for your help,
R
2 Answers:
Lukus - thanks for your quick reply and the recommendation for the Java API site.
The method you suggested allowed me to combine the text and the field value but I wasn't able to format the number within the string as currency.
However, I was able to find (through the API and these forums) a method to do so that seems to work:
"the first part of the sentence I wanted " + NumberFormat.getCurrencyInstance().format($F{OrigLoanBal}) + "the last part of the sentence I wanted."
Thanks again for your help - your suggestion broke my log jam.
R