Number patterns
Numbers, used in a template, can be displayed using a custom pattern.
In the Script Editor, the pattern can be passed to a function of the formatter
; see formatter. The custom pattern may consist of pattern characters (see below), a prefix and a suffix.
All data fields contain strings (except when a CSV or Microsoft Excel file was loaded).
Note that strings need to be converted to a number before they can be formatted this way.
The repetition of pattern letters determines the exact presentation. For example, the pattern "00000" limits the number to 5 digits and adds leading zeros to any numbers that are not 5 digits long.
Note: In output, spaces in a number or amount of money are transformed into non-breaking spaces to ensure that it is not split onto different lines.
Pattern characters
Symbol | Location | Localized? | Meaning |
0 | Number | Text | Digit |
# | Number | Year | Digit, zero shows as absent |
. | Number | Year | Decimal separator or monetary decimal separator |
- | Number | Month | Minus sign |
, | Number | Number | Grouping separator |
E | Number | Number | Separates mantissa and exponent in scientific notation. Need not be quoted in prefix or suffix. |
; | Subpattern boundary | Number | Separates positive and negative subpatterns |
% | Prefix or suffix | Number | Multiply by 100 and show as percentage |
\u2030 | Prefix or suffix | Number | Multiply by 1000 and show as per mille value |
¤ (\u00A4) | Prefix or suffix | Number | Currency sign, replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator. |
' | Prefix or suffix | Text | Used to quote special characters in a prefix or suffix, for example, "'#'#" formats 123 to "#123". To create a single quote itself, use two in a row: "# o''clock". |
Source: http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html.