BIRT - Change decimal separator - period v/s comma - birt

Based on a global variable how can i set the number formatter i.e. Setting comma as decimal separator as opposed to period. Also, changing Date format pattern based on a global variable.
i.e 1234.56 = 1234,56
Where can i do this? crosstab? and what expression to use?
Thanks in advance.

For numbers you can do it with an expression:
params["SomeVar"].value == 'format1'?
Formatter.format(valueToDisplay,"0,00"):
Formatter.format(valueToDisplay,"0.00");
Don't know if Formatter works with Date values.

Related

Format currency with dot instead of comma using i18n

We are using java.text.NumberFormat class to format the currency values using the method getInstance(Locale paramLocale). Our issue is when we pass es_CO(Columbia) language code it automatically formats it in value 123,00 instead of 123.00. Is there a way to format with dot instead of comma?
I am using Spring platform(hybris)
Please note due to business reasons it is not possible for me to change the locale.
You can use DecimalFormat to have your own format.
Look at this How can I format a String number to have commas and round?

Formatting numbers with thousand separator as empty string on amcharts4

I need to format the chart number format so that numbers stop looking like that 1,525 (comma separator) and start looking like this 1 525 (empty string thousand separator). Plus, I need dot separator for decimal, but only if a number has any, like this 1 525.4
The closest number format I was able to find for amCharts4 version is
chart.numberFormatter.numberFormat = '#,###.#';
Any ideas?
So, after a research I've found a solution - you have to use locales.
This line of code helped me a lot:
chart.language.locale = am4lang_[locale];
For empty string separator I used am4lang_ru_RU.
Btw, if you need to make your own number, strings, etc formatting, you can create your locales for that.

Progress amount format in PDF

I want to show amount like this format 100,000,000.00. In my code i defined variable like this
DEFINE VARIABLE mAMOUNT AS INTEGER FORMAT "999,999,999,999,99.99".
and mAMOUNT = 100,000,000.00and how ever i got amount like this 100000000 Plz help me
define variable amount as decimal ">>>,>>>,>>>,>>9.99" no-undo.
amount = 123456789.01.
display amount.
"9" in a FORMAT phrase forces a digit to be shown -- you might have an "all 9s" format if you wanted leading zeros but that is unusual.
If you intend to have decimal places you need to use the DECIMAL datatype, not INTEGER.

FreeMarker convert string with commas to number

I need to convert a locale specific string value having either commas or dot in between to indicate thousands separator, to a number in FreeMarker by removing the decimal places. For example: 13,456.79 to 13,456 OR 23.675,98 to 23.675
Using ?number throws exception saying this string can't be converted to a number. I see a similar question here:
Convert string with commas into integer in Freemarker but no solution exist. Is there a way to do so?
I would parse the variable as Integer before (in the Controller/Business layer) exposing it to the template (and react in case of problems with the format).
In my opinion templates should handle nothing more than the presentation of (valid) data.
Alternately...
You can try to transform the string...
<#function string_to_int s >
<#local a = s?replace(",", "") >
<#return a?keep_before_last(".") />
</#function>
${string_to_int("13,456.79")}
will output
13456
Given the limitations like locale specific numbers where decimal and thousands separator characters can either be a dot or a comma, and since I only needed to display the value and not do any numeric calculations based on the number value, I resolved this by simply ignoring the last 3 characters of the string using substring. This will remove the decimal separator and 2 decimal places (assumption being that there are always 2 decimal places).

Jmeter - how to add prefix to a counter. Similar to a random variable

Currently in the random variable I can put a prefix or suffix in the output format of the variable. However this nice feature is not available for a simple counter controller. Concatenating string+${counter} every time when i use the variable is not a good option form me since i do this a lot.
Is there any way to achieve prefix+counter in a way random variable do this?
Thanks.
Are you talking about Counter Config Element ?
If so it is possible using Number Format attribute:
http://jmeter.apache.org/usermanual/component_reference.html#Counter
See:
Format Optional format, e.g. 000 will format as 001, 002 etc.
This is passed to DecimalFormat, so any valid formats can be used.
If there is a problem interpreting the format, then it is ignored.
[The default format is generated using Long.toString()]
On 'Number format' field of Counter, write your pattern with 0...0 represents for value count up.
Example:
'Number format' pattern: prefix_000_suffix
Real value: prefix_001_suffix, prefix_002_suffix, prefix_003_suffix,...
Hope this helps!

Resources