Textfield pattern


Hi There!

I'm trying to put a textfield in static text. The final text has to be like this: "The amount of $123.45 will be debited from your account."

My first try was to create 1 textfield with this expression: "The amount of "+ $F{amount} +"will be debited from your account."

Generally, this works. But I want to format the $F{amount} as a currency. Without a pattern the number is shown as 123.450000000000.
But because I put static text in the textfield expression, the datatype is handled as "String" not as "Double".

When I use the contruction [Static Text][Textfield][Static text], I get a lot of white space before and after the amount.....

How could I fix this?

Thanks a lot in advance!!!!!!

Kind regards,
Marco Mans

mmans's picture
Joined: Aug 5 2010 - 10:43pm
Last seen: 5 years 2 months ago

3 Answers:


Hi mmans ,

What you can do to fix this is, set the expression for 1 textfield as :

 "The amount of  "+new java.text.DecimalFormat("¤ #,##0.00").format($F{amount}) + "  will be debited from your account."

The field which you use to display this would be a single textfield , with no changes in pattern and the Expression class would be java.lang.String

This will fix the issue. 




Ankur Gupta's picture
Joined: Jan 21 2013 - 10:36pm
Last seen: 3 months 18 hours ago

Sorry, but you DO NOT put "put a textfield in static text"... What you are doing is concatenating a literal text with a field of type double (or similar), and present the result of that expression in a text field.

What you have to do is to format the number within the text fields expression. There are different possibilities of doing that, depending on the java version you are using.

Have a look here:


or here:


However, it should result in an exspression for your text field like:

String.format("The amount of $%5.2f will be debited from your account.", $F{theamount}


"The amount of $" + $P{mynumformatter}.format(dd)).doubleValue() + "will be...."

where $P{mynumformatter} has a default value like

new DecimalFormat( "#,###,###,##0.00" )

Is far as I remember, the report has a default parameter "REPORT_FORMATTER" which can do similar.

I hope this helps.

Cheers, Thomas


Thomas Zimmer's picture
Joined: Oct 2 2012 - 1:35am
Last seen: 1 week 9 hours ago

Thanks for both answers. I got it working now.

When using Japser I still have to get used to the fact, that I can use "The-Standard-Java-Way" (tm) :D



mmans's picture
Joined: Aug 5 2010 - 10:43pm
Last seen: 5 years 2 months ago