Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Getting
kosta
Hello BIRT Community,<br />
<br />
Code in expression builder in a data element from table cell:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var test= new Number(dataSetRow["test"]);
test.toLocaleString()
</pre>
<br />
This always code returns dot separated values (3.111). <br />
But I need comma separated values (3,111).<br />
<br />
I also set the locale before run like <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
Locale locale = new Locale("de", "DE");
task. setLocale(locale);
</pre>
but this didn't work well. Still got (3.111)<br />
<br />
The others data elements where set to float and there the floating number property work well. Only the function "toLocaleString()" in the "Expression Builder" returns locale independent value.<br />
<br />
I am using the Expression Builder because sometimes the output will contain other signs (">" or "<") near the float value.<br />
<br />
Maybe there is other solution for this one but this can be bug so I wanted to mention it here.<br />
<br />
Thanks.
Find more posts tagged with
Comments
JasonW
Does it work if you put in:
importPackage( Packages.java.text );
importPackage( Packages.java.lang );
nf = NumberFormat.getNumberInstance( reportContext.getLocale() );
nf.setMinimumFractionDigits(2);
str = nf.format( new Double(dataSetRow["test"]));
Jason
kosta
Thank you Jason,
importing java packages and using pure java in the expression builder is something that I didn't knew until now. I thought this can only be done in the script view. Have learned something new today.