The numberStyle used in formatting InternationalTokens tokens is shown below:

"currency"

A currency format.

"percent"

A percentage format.

"integer"

An integer format.

numberFormatPattern

see below

numberFormatPattern

The following shows the structure of the pattern.

pattern := subpattern{;subpattern}
subpattern := {prefix}integer{.fraction}{suffix}
prefix := '\\u0000'..'\\uFFFD' - specialCharacters
suffix := '\\u0000'..'\\uFFFD' - specialCharacters
integer := '#'* '0'* '0'
fraction := '0'* '#'*

Notation:

X* 0 or more instances of X
(X | Y) either X or Y.
X..Y any character from X up to Y, inclusive.
S - T characters in S, except those in T

A pattern can consist of one or two subpatterns. The first subpattern defines to format for positive numbers. and the second (optional) subpattern defines the format for negative numbers.

Below are shown the special characters used in the parts of the subpattern.

Symbol

Meaning

0

A digit

#

A digit but zero shows as absent.

.

A placeholder for a decimal separator.

,

A placeholder for a grouping separator.

E

Separates mantissa and exponent for exponential formats.

;

Separates formats.

-

The default negative prefix.

%

Multiply by 100 and show as percentage.

?

Multiply by 1000 and show as per mile.

¤

The currency sign; replaced by the currency symbol. If doubled it is replaced by the international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator.

X

any other characters can be used in the prefix or suffix

'

Used to quote special characters in a prefix or suffix.

If there is no explicit negative subpattern, then a minus sign (-) is prefixed to the positive form. That is, "0.00" alone is equivalent to "0.00;-0.00". If there is an explicit negative subpattern, it serves only to specify the negative prefix and suffix; the number of digits, minimal digits, and other characteristics are all the same as the positive pattern. That means that "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)".

If the maximum number of fraction digits is lower than the actual number of fraction digits, then the result will be rounded to the maximum number of fraction digits. The rounding is performed according to the IEEE 754 default rounding mode known as half even: Numbers are rounded toward the nearest truncated value, unless both truncated values are equidistant, in which case the value ending in an even digit is chosen.

The exponent character must be immediately followed by one or more digit characters. Example: "0.###E0". The number of digit characters after the exponent character gives the minimum exponent digit count; there is no maximum. Negative exponents are denoted using the same prefix and/or suffix specified for the number itself. The minimum number of integer digits is achieved by adjusting the exponent. The maximum number of integer digits, if any, specifies the exponent grouping. For example, 12345 is formatted using "##0.###E0" as "12.345E3".

Illegal patterns, such as "#.#.#" or mixing '_' and '*' in the same pattern, will cause the formatting to be ignored.

The grouping separator is commonly used for thousands, but in some countries for ten-thousands. The interval is a constant number of digits between the grouping characters, such as 100,000,000 or 1,0000,0000. If you supply a pattern with multiple grouping characters, the interval between the last one and the end of the integer is the one that is used. So "#,##,###,####" == "######,####" == "##,####,####".

Below are some examples using the US locale:

Format Pattern

Result

"#,##0.0#;(#)"

1,234.0

"##0.###E0"

1.234E3

"¤##.##"

$1234

"¤¤##.##"

USD1234

Comment on this topic

Topic ID: 150074