com.jaxfront.core.jep
Class Format
java.lang.Object
org.nfunk.jep.function.PostfixMathCommand
com.jaxfront.core.jep.JaxfrontMathCommand
com.jaxfront.core.jep.Format
- All Implemented Interfaces:
- org.nfunk.jep.function.PostfixMathCommandI
public class Format
- extends JaxfrontMathCommand
DecimalFormat is for formatting decimal numbers with usage of a patterns.
Symbol Meaning 0 a digit # a digit, zero shows as absent . placeholder for
decimal separator , placeholder for grouping separator. E separates mantissa
and exponent for exponential formats. ; separates formats. - default negative
prefix. % multiply by 100 and show as percentage ‰ multiply by 1000 and show
as per mille ¤ 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. X any
other characters can be used in the prefix or suffix ' used to quote special
characters in a prefix or suffix.
Notes
If there is no explicit negative subpattern, - 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#)".
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 an IllegalArgumentException to be thrown. From the message of
IllegalArgumentException, you can find the place in the string where the
error occurred.
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 "#,##,###,####" ==
"######,####" == "##,####,####".
- Version:
- 1.60
Constructor Summary |
Format()
Constructor. |
Methods inherited from class org.nfunk.jep.function.PostfixMathCommand |
getNumberOfParameters, getRootNode, run, setCurNumberOfParameters |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Format
public Format()
- Constructor.
format
public java.lang.String format(MathEvaluator.MathCommunicator communicator,
java.lang.Number number,
java.lang.String pattern)
- Method format calls the java.text.DecimalFormat class with the given
parameters.
- Parameters:
number
- pattern
-
- Returns:
- String
format
public java.lang.String format(MathEvaluator.MathCommunicator communicator,
java.lang.Object value,
java.lang.Object pattern)
throws org.nfunk.jep.ParseException
- Method format.
- Parameters:
value
- pattern
-
- Returns:
- String
- Throws:
org.nfunk.jep.ParseException
run
public void run(MathEvaluator.MathCommunicator communicator,
java.util.Stack stack)
throws org.nfunk.jep.ParseException
- Specified by:
run
in class JaxfrontMathCommand
- Throws:
org.nfunk.jep.ParseException
- See Also:
org.nfunk.jep.function.PostfixMathCommandI#run(Stack)