Values accepted by the "Format" property of different elements
These properties are used to display in a deciaml format values of type double or int. It would be too lengthy to describe all possibilities for the objects of the valid class (java.text.DecimalFormat), but we can extract the basic information (which is generally enough) from its reference page.
A format structure consists in a substructure for the positive
values and a second one for the negative values, such as:
\#,\#\#0.00;(\#,\#\#0.00)
Each substructure contains a prefix, a numeric part and a suffix.
The substructure for the negative values is optional. If not provided, then the positive substructure is used, with an added negative sign, for the negative values. Hence, if we write simply x=0.00, this is equivalent to x=0.00;x=-0.00. If there is an explicit negative substructure, then this is used only to indicate the cooresponding prefix and suffix. This means that \#,\#\#0.0\#;(\#) produces the same behavior as \#,\#\#0.0\#;(\#,\#\#0.0\#).
The prefixes, suffixes and various symbols used by the format can be set to any values, and will appear properly when fromatting. Care must be taken, though, so that the symbols and texts do not conflict, or it would be impossible to sample the values when required. For instance, the prefixes for the psotive an dnegative values must be differetn so that the class can distinguish between positive and negative values. (If they were identical, then DecimalFormat would act as if no negative substructure had been specified.) A second example is that different characters must be used for the decimal and thousand separators, or it would be impossible to sample a value.
Illegal structures, such as \#.\#.\# or \#.\#\#\#,\#\#\#, will cause an IllegalArgumentException exception from DecimalFormat, together with a message describing the problem.
Structure syntax:
struc := positive_struc{';' negative_struc}
positive_struc:= {prefix}number{suffix}
negative_struc:= {prefix}number{suffix}
number:= integer{'.' fraction}{exponent}
prefix:= '\u0000'..'\uFFFD' - special_characters
suffix := '\u0000'..'\uFFFD' - special_characters
integer := min_integer | '#' | '#' integer | '#' ',' integer
min_integer := '0' | '0' min_integer | '0' ',' min_integer
fraction := '0'* '#'*
exponent := 'E' '0' '0'*
Notation:
X* 0 or more occurences of X
{ X } 0 or 1 occurences of X
X | Y X or Y
X..Y any character from X to Y, included
S - T characters in S, except those in T
Practical hint.
After all this terrible jargon, here comes a
simple practical hint. Use structures such as the following:
Name =
#.00;Name = - #.00
if you want to display two decimal figures (add more zeros if you want), for
variables of type double, and structures such as:
Name = 0;Name = - 0
for integers. In both cases, replace Name by the name of the
variable displayed.