2

I am using iReports to generate Reports. I want to display the GrandTotal fields in Indian Numbering Format. For Example,

Value: 1,000,000 should be displayed as 10,00,000

I tried using Pattern of text field properties, but not able to get the result. And in some forums they have mentioned to use JRParameter.REPORT_LOCALE. I tried this way

Locale locale = new Locale("en", "IN");
parameters.put(JRParameter.REPORT_LOCALE, locale);

where parameters is a map which is then used to fill report.

Any help is appreciated

Thanks

Srikanth Sridhar
  • 2,317
  • 7
  • 30
  • 50

1 Answers1

2

If you use ICU4J you can do something like

com.ibm.icu.text.NumberFormat.getCurrencyInstance(new Locale("en", "in")).format(new Java.math.BigDecimal(${FIELD_HOLDING_THE_VALUE}));

NumberFormat of ICU4J is explained in this thread

Community
  • 1
  • 1
Bnrdo
  • 5,325
  • 3
  • 35
  • 63
  • how to include this in iReports ? Please guide – Srikanth Sridhar Feb 08 '13 at 10:05
  • 2
    You need to add the icu4j jar into the iReport class path as well where ever the report is deployed to. – MrsTang Feb 08 '13 at 10:10
  • ok, is there a way to generalize this, I want it to get applied to all my reports, by using some JRParameter ? – Srikanth Sridhar Feb 08 '13 at 10:12
  • Since you're already passing your desired locale to REPORT_LOCALE parameter inside the report, you can just replace the part `new Locale("en", "in")` in my answer with `$P{REPORT_LOCALE}` – Bnrdo Feb 08 '13 at 10:17