Java uses the Locale class to handle locale-specific data formats for currency, date, numbers, and messages. Locale is a combination of country and language that identifies a particular combination of formats for internationalization This blog post shows an internationalized handling of number formats.
In the U.S., decimal numbers use a dot for a decimal separator and a comma for a thousands separator.
Other countries represent decimal numbers using the comma as a decimal separator and a dot for a thousands separator.
There are other variations. A space could be used for a thousands separator. There may be no thousands separator.
To handle this in Talend Open Studio, a tMap can invoke Java parsing routines that are driven by a Locale. In this tMap example, two variables are declared 'usVar' and 'itVar' that are String constants of different number formats. The tMap will use the NumberFormat class to parse the numbers into a double.
|Locale Used in a Talend tMap|
The output schema is using a Double. If using a BigDecimal for additional precision or integration with other libraries, see the Talend Forum page http://www.talendforge.org/forum/viewtopic.php?id=15502.
If these classes -- NumberFormat, Locale -- are used repeatedly, it's worthwhile to import the classes using a tJava. On the "Advanced settings" tab, put "import java.util.Locale" and "import java.text.NumberFormat" (no quotes). Then, the package of java.text.NumberFormat can be removed.
You can handle your internationalized data using Java's Locale class. This example converted String numbers in different formats to a common Java type (Double). Other uses of Locale include Date (month/day/year versus day/month/year), currency ($100 versus €100), or messages.