Number format

By: gabyem - gabyem
Number format
2005-03-07 11:33
Hello! I am building a report with iReport and Jasper Report. It works fine but I cant change the numbers to use '.' as decimal separator and ',' as thousand separator.

I tryed changing the pattern and it did not work.
I changed the regional settings on the computer and it did not work either.

I will appreciate any help! Thanks

By: allie - allie910
RE: Number format
2005-06-13 20:39
Hi There,
sorry, but are u sure u are using the right pattern ? I'm using #,##0.00 and it's working fine with me =)

The way that i'm showing a bigecimal variable using a textfield and set the value class of the textfield as : java.math.BigDecimal and set the pattern to the textfield as well ;)

hope this can help u

By: Giulio Toffoli - gt78
RE: Number format
2005-06-14 07:54
Please note that #,##0.00 is Locale indipendent, so in Italy the result of:


will be:


2002 JI Open Discussion's picture
Joined: Aug 10 2006 - 3:28am
Last seen: 13 years 5 months ago

4 Answers:

It doesn't seem to work.
I am developing a java application on an italian server, but want numbers to come in english format, and i keep getting wrong formatting.
i want 1,234.56 but i get 1.234,56.

i passed to jasper the parameter REPORT_LOCALE as desired but it seems the JasperReports 2.0.4 doesn't use it to format the numbers.

the problem is that in iReports exports it is correct, only the web generated pdf is wrong.

I checked here but they all suggest using custom java classes or scriptlets to do this, but is there a way to make this with default jasper reports features and locales ??

hopesolutions's picture
Joined: Mar 17 2008 - 9:01pm
Last seen: 11 years 10 months ago
textfield expression/string

<br />
NumberFormat.getInstance().getCurrencyInstance(Locale.ITALIAN).format($F{somenumberfield})+" / "+NumberFormat.getCurrencyInstance(Locale.US).format($F{somenumberfield})</td></tr></tbody></table>
momzilla's picture
Joined: Jul 27 2006 - 11:52am
Last seen: 13 years 6 months ago
Hi hope.

There is one questionable way, if u'r using JRTextField to display this amount. :)
U say u want 1,234.56 instead of 1.234,56. If u can get the amount(1,234.56) as a String(by changing the field's Expression Class to java.lang.String), u can simply call replace(String, String) in the Text Field's Expression. But in order to keep the amount formating u got to use also DecimalFormat(only if u'r thousand separator is space). So this 'workaround' looks something like this:
DecimalFormat.getInstance().format($F{AMOUNT}).replaceFirst(",", ".")
Or something like that.

good luck!
extendet's picture
Joined: Dec 7 2009 - 12:22am
Last seen: 10 years 1 month ago

if  $F{ImporteTotal} is a BigDecimal

Try with this (in the Text Field Expression):


That's working for me.



mfoglino's picture
Joined: Jan 29 2010 - 10:47am
Last seen: 10 years 1 day ago