Package org.kissweb
Class NumberFormat
java.lang.Object
org.kissweb.NumberFormat
Advanced method for formatting numbers.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
NumberFormat
public NumberFormat()
-
-
Method Details
-
Formatb
Numeric formatter. Takes a double and converts it to a nicely formatted String in a specified number base.- Parameters:
num
- number to be formattedbase
- numeric base (like base 2 = binary, 16=hex...)msk
- format mask - any combination of the following:
- B = blank if zero
- C = add commas
- L = left justify number
- P = put parentheses around negative numbers
- Z = zero fill
- D = floating dollar sign
- U = uppercase letters in conversion
- R = add a percent sign to the end of the number
wth
- total field width (0 means auto)dp
- number of decimal places (-1 means auto)- Returns:
- the formatted String
example:
String r = Formatb(-12345.348, 10, "CP", 12, 2);
result in r: "(12,345.35)" - See Also:
-
Format
Numeric formatter. Takes a double and converts it to a nicely formatted String (for number in base 10).- Parameters:
num
- number to be formattedmsk
- format mask - any combination of the following:
- B = blank if zero
- C = add commas
- L = left justify number
- P = put parentheses around negative numbers
- Z = zero fill
- D = floating dollar sign
- U = uppercase letters in conversion
- R = add a percent sign to the end of the number
wth
- total field width (0 means auto)dp
- number of decimal places (-1 means auto)- Returns:
- the formatted String
example:
String r = Format(-12345.348, "CP", 12, 2);
result in r: "(12,345.35)" - See Also:
-
main
Test function.- Parameters:
argv
-
-