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

Decimal format issue


xmcamino

Recommended Posts

Hello,

I have a decimal issue in my report. I use the expression: new java.text.DecimalFormat("##0.0").format($F{score})

and I want decimals with point (.) not with comma (,) in the 'score' value. I am using jasperstudio on windows 10.

How can I fix this, please?

Regards,

MAC

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi xmcamino,

What is the type of your field ? For a double or a Big Decimal you can use this : String.format("%,.2f",$F{field_name})

.2f is for a dot as a separator then 2 floating point on a decimal number. But my locale is 'France' on my PC so the dot become a comma.

Examples :

System.out.format("%.3f%n", pi);     // -->  "3.142"System.out.format("%10.3f%n", pi);   // -->  "     3.142"System.out.format("%-10.3f%n", pi);  // -->  "3.142"System.out.format(Locale.FRANCE,"%-10.4f%n%n", pi); // -->  "3,1416"

https://docs.oracle.com/javase/tutorial/java/data/numberformat.html

You can check on your locale or set the locale directly in the format function.

Hope it will help you,

Yann

Link to comment
Share on other sites

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