Default number formatting Internatinoal number formatting issue
#1
Posted 19 June 2012 - 03:16 AM
I'm using BIRT 2.5.2,
I have a strange issue related to the default number formatting.
The system decimal separator is not used when the report Data value is of type decimal and float.
same issue when using Dynamic Text instead of Data box.
Only when a Data field is used and the type is set to String, the correct decimal separator is used!
My PC is set to use German format so I'm expecting to have a decimal values separated by commas instead of dots.
Ex. Expected : 0,33
Dynamic text: Math.round(1/3*100)/100 => 0.33 -WRONG
Data field: Math.round(10*5/3*100)/100 Data Type: Decimalor Float => 0.33 -WRONG
Data field Math.round(10*5/3*100)/100 Data Type: String => 0,33 - OK
Any help is appreciated.
Thanks in advance
#3
Posted 19 June 2012 - 10:37 AM
#4
Posted 19 June 2012 - 12:55 PM
mwilliams, on 19 June 2012 - 11:37 AM, said:
Hi Michael,
Thanks for your quick answer, I have not changed the locale in the BIRT Report Designer (2.5.2) but checking that under Preferences I have remarked that the selected local was dansk(Danmark), as previously I have changed the PC local to Denmark, and the only problem is that the selected local (detected automatically by the RCP Designer) started with lowercase d - using this as previously mentioned only the Data field of type String was correctly formatted.
Changing that to uppercase D - Dansk(Danmark) both Data fields of type String and Decimal are correctly formatted.
BUG: Auto detected locals in BIRT RCP Designer 2.5.2 for Denmark system format, start with lowercase letter and the decimal number formatting is wrong, only the Data fields of type String are correctly formatted.
How to reproduce : Set PC Format (Under Regions and Languages) to Danish (Denmark) then Open/Restart BIRT RCP Designer -> Window -> Preferences -> Select Report Design then Preview
Empty the field "Choose your locale" then select Apply and OK, reopen the Preferences window will show the default locale starting with lowercase letter like this : dansk (Danmark)
Is there a simple way to set the correct decimal number formatting for a Dynamic Text Box or we must use a Data fields instead?
Thanks in advance
#5
Posted 19 June 2012 - 02:08 PM
importPackage (Packages.java.text); importPackage (Packages.java.util); temp = 0.33; nf = NumberFormat.getInstance(Locale.GERMAN); nf.format(temp);
#6
Posted 19 June 2012 - 09:38 PM
mwilliams, on 19 June 2012 - 03:08 PM, said:
importPackage (Packages.java.text); importPackage (Packages.java.util); temp = 0.33; nf = NumberFormat.getInstance(Locale.GERMAN); nf.format(temp);
Thanks a lot it works well, just one more question related to this, is it necessarily to use this code for using the default number formatting for Dynamic Text:
importPackage (Packages.java.text); importPackage (Packages.java.util); temp = 0.33; nf = NumberFormat.getInstance(); nf.format(temp);
or it has been fixed in the recent BIRT versions ( > 2.5.2) so the dynamic text is automatically formatted with the default locale?
Thanks in advance
#7
Posted 20 June 2012 - 05:11 AM
daniel_v, on 19 June 2012 - 10:38 PM, said:
importPackage (Packages.java.text); importPackage (Packages.java.util); temp = 0.33; nf = NumberFormat.getInstance(); nf.format(temp);
or it has been fixed in the recent BIRT versions ( > 2.5.2) so the dynamic text is automatically formatted with the default locale?
Thanks in advance
HI again,
In the report designer the following code works well :
importPackage (Packages.java.text); importPackage (Packages.java.util); temp = 0.33; nf = NumberFormat.getInstance(); nf.format(temp);
But does not work into my report viewer, I have specified the __locale parameter as __locale=da_DK
It seams that the default Locale used by the report viewer is not that specified by the __locale parameter?
Thanks in advance
PS: I have remarked that there are lot of SPAM replies to this topic :S
#9
Posted 20 June 2012 - 09:07 PM
mwilliams, on 20 June 2012 - 06:49 AM, said:
Hi Michael,
Thanks again for your answer, YES, setting the Locale into the format works well
i.e
i.e. nf = NumberFormat.getInstance(new Locale("da","DK"));
But this solution does not solve my problem as I need to have dynamic locale in the reports - specified in the report URL (... __locale=<user_locale>)
Example:
http://localhost:8900/WebViewerExampel/frameset?_-report=MyReport.rptdesign&__locale=fr_CA
Into the BIRT documentation I have found the following about the _locale parameter :
Quote
Note that this will override the default locale.
Order of precedence is as follows:
__locale parameter.
Locale from client browser.
Locale web.xml setting.
Locale for the application server.
But it seams that is not working like this on my report viewer 2.5.2
Any suggestions are very appreciated!
Thanks in advance
#10
Posted 20 June 2012 - 09:08 PM
mwilliams, on 20 June 2012 - 06:49 AM, said:
Hi Michael,
Thanks again for your answer, YES, setting the Locale into the format works well
i.e
i.e. nf = NumberFormat.getInstance(new Locale("da","DK"));
But this solution does not solve my problem as I need to have dynamic locale in the reports - specified in the report URL (... __locale=<user_locale>)
Example:
http://localhost:8900/WebViewerExampel/frameset?_-report=MyReport.rptdesign&__locale=fr_CA
Into the BIRT documentation I have found the following about the _locale parameter :
Quote
Note that this will override the default locale.
Order of precedence is as follows:
__locale parameter.
Locale from client browser.
Locale web.xml setting.
Locale for the application server.
But it seams that is not working like this on my report viewer 2.5.2
Any suggestions are very appreciated!
Thanks in advance
#11
Posted 20 June 2012 - 09:45 PM
importPackage (Packages.java.text); importPackage (Packages.java.util); temp = 0.33; localeCode = reportContext.getLocale(); lang = localeCode.getLanguage(); country = localeCode.getCountry(); nf = NumberFormat.getInstance(new Locale(lang,country)); nf.format(temp);
#12
Posted 20 June 2012 - 10:07 PM
Quote
and that is the reason why the number formatting is wrong in my reports.
All I need is to have a number formatting based on the __locale parameters specified in the report URL,
and it seams that the only way is to use Data boxes with Decimal data type specified?
Note: I'm using BIRT Viewer 2.5.2
Any help is appreciated!
Thanks in advance
#13
Posted 20 June 2012 - 10:08 PM
mwilliams, on 20 June 2012 - 10:45 PM, said:
importPackage (Packages.java.text); importPackage (Packages.java.util); temp = 0.33; localeCode = reportContext.getLocale(); lang = localeCode.getLanguage(); country = localeCode.getCountry(); nf = NumberFormat.getInstance(new Locale(lang,country)); nf.format(temp);
Ahh using the report context locale instead of the system locale, I will check it and back to you shortly,
Thanks
#14
Posted 20 June 2012 - 10:15 PM
mwilliams, on 20 June 2012 - 10:45 PM, said:
importPackage (Packages.java.text); importPackage (Packages.java.util); temp = 0.33; localeCode = reportContext.getLocale(); lang = localeCode.getLanguage(); country = localeCode.getCountry(); nf = NumberFormat.getInstance(new Locale(lang,country)); nf.format(temp);
This solution works great (the number formatting in now based on the __locale parameter specified in the report URL).
Is this issue fixed in the recent BIRT versions (>2.5.2)?
I think that by default the number formatting should be based on the __locale parameter
Thanks for your help
#15
Posted 22 June 2012 - 07:05 AM






MultiQuote





