Number Formatting
Number Formatting is used by the Flat File parser and composer and Integer, Float and String objects (e.g. parseFloatExpression() Operation, printFloatExpression() Operation, parseIntegerExpression() Operation, printIntegerExpression() Operation).
Locale characters are by default the system locales. These can be overridden by providing a Locale structure as input parameter to Flat File parser/composer or action script functions.
The format processor uses similar patterns as Oracle and PostgreSQL but is not 100% compatible e.g. there's no support for scientific and roman notation.
All parse and compose functionality is influenced by locales. The Flat File adapter and the parse and print number operations take a parameter of type Basic Components.Basic Behavior.NumbersLocale. This parameter can be used to specify the following settings:
Class | Attribute | Type | Description |
---|---|---|---|
NumbersLocale | negativeSign | String | Characters used to signify negative values. Usually ' |
positiveSign | String | Characters used to signify positive values. Usually ' | |
thousandsSeparator | String | Characters used to separate units of thousand, e.g. ' | |
decimalPoint | String | e.g. ' | |
currencySymbol | String | e.g. ' |
To specify a number format, the attribute must have the stereotype FlatFileAttribute. Default values are given by the system locales.
Patterns
This table shows the template patterns available for formatting numeric values.
Pattern | Description |
---|---|
| Value with the specified number of digits. |
| Value with leading zeros. |
| Decimal point. |
| Group (thousand) separator. |
| Negative value in angle brackets. |
| Sign anchored to number (uses locale). |
| Currency symbol (uses locale). |
| Decimal point (uses locale). |
| Group separator (uses locale). |
| Minus sign in specified position (if number < 0). |
| Plus sign in specified position (if number > 0). |
| Plus/minus sign in specified position. |
| Ordinal number suffix. |
| Shift specified number of digits (see notes). |
| Fill mode prefix, will discard any leading spaces. |
Usage Notes
A sign formatted using SG, PL, or MI is not anchored to the number; for example,
to_char(-12, 'S9999')
produces ' -12', butto_char(-12, 'MI9999')
produces '- 12'.9 results in a value with the same number of digits as there are 9s. If a digit is not available it outputs a space.
TH does not convert values less than zero and does not convert fractional numbers.
V effectively multiplies the input values by 10^n, where n is the number of digits following V.
to_char()
does not support the use of V combined with a decimal point. (E.g., 99.9V99 is not allowed.)Locale characters are by default the system locales. These can be overriden by providing a Locale structure as input parameter to flatfile parser/composer or script function.
Examples
The examples below use the following locale:
Locale Setting | Value |
---|---|
Negative sign | - |
Positive sign | + |
Thousands separator | (blank) |
Decimal point | , |
Currency symbol | $ |
Number | Format | Output String | Description |
---|---|---|---|
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| Parsing not possible. |
|
|
| |
|
|
| no leading zeros ( |
|
|
| |
|
|
| leading blank comes from the plus sign, that is not displayed |
|
|
| |
|
|
| |
|
|
| hard coded group separator |
|
|
| group separator from locale |
|
|
| hard coded decimal point |
|
|
| decimal point from locale |
|
|
| group separator and decimal point from locale |
|
|
| value increased by factor 1000, because 3 digit are following the specification of |
|
|
| value increased by factor 1000, because 3 digit are following the specification of |
|
|
| value increased by factor 10, because 1 digit is following the specification of |
|
|
| displaying the sign from locale in rear of the number |
|
|
| displaying a minus sign in rear of the number, if number is negative |
|
|
| no minus sign added if number is positive, but empty space instead |
|
|
| adding a plus sign in front of number if number is positive ( |
|
|
| adding no plus sign in front of number because number is not positive (PL), negative system sign, no trimming of leading spaces |
|
|
| displaying a plus sign in rear of the number, if number is positive ( |
|
|
| displaying a plus sign in rear of the number, if number is positive ( |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| displaying the currency symbol in front of the number ( |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
|
Related Pages: