Jump to content
We've recently updated our Privacy Statement, available here ×

Number format


Recommended Posts

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:

 

#,##0.00

 

will be:

 

1.234,56

 

Giulio

Link to comment
Share on other sites

  • 1 year later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

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 ??

 

Thanks

Link to comment
Share on other sites

  • 1 year later...

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!

Link to comment
Share on other sites

  • 1 month 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...