Package quadbase.util
Class NumericFormat
java.lang.Object
quadbase.util.NumericFormat
- All Implemented Interfaces:
IFormat
NumericFormat
NumericalFormat is a utility class to format numeric value. You can specify the no. of decimal point, currency symbol, thousand separator etc.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionintcurrency position, 0 - before number (default), 1 - after negative sign, 2 - after number, 3 - after number and negative sign.charDeprecated.intdecimal point, range from 1 to 6, default 2chardecimal point char, default '.'booleanleading zero, 0 or 1intnegative position, 0 - before currency sign (default), 1 - after currency sign, 2 - end of numberbooleanDeprecated.not used.intno.booleaneither 0 or 1, invalid when not currency, default 0charthousand separator, if 'N' means no thousand separator.Fields inherited from interface quadbase.util.IFormat
DATETIME, LOCALEDATETIME, LOCALENUMERIC, LOGICAL, NUMERIC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDefine quadbase.util.IFormat.Get custom multi-character currency symbol Deprecates the old char type currency symbol variable "currencySymbol"intDefine quadbase.util.IFormat.output(double d) Output the formatted number.voidsetCustomCurrency(String customCurrency) Set custom multi-character currency symbol Deprecates the old char type currency symbol variable "currencySymbol"voidSet all variables to default valuevoidsetFormat(char currSymInit, boolean oneSymPerPageInit, int currencyPosInit, int decimalInit, int roundingInit, int negativeInit, char decimalSepInit, char thousandSepInit, boolean leadingZeroInit) Set Numeric format.voidsetFormat(char currSymInit, boolean oneSymPerPageInit, int currencyPosInit, int decimalInit, int roundingInit, int negativeInit, char decimalSepInit, char thousandSepInit, boolean leadingZeroInit, String customCurrency) Set Numeric format.voidsetScientifExp(int precision) Set scientific expressiontoString()
-
Field Details
-
sciExp
public boolean sciExpeither 0 or 1, invalid when not currency, default 0 -
currencySymbol
Deprecated.currency symbol, default none -
oneSymPerPage
Deprecated.not used.Not used. Always false. -
currencyPos
public int currencyPoscurrency position, 0 - before number (default), 1 - after negative sign, 2 - after number, 3 - after number and negative sign. Invalid when not currency. -
decimal
public int decimaldecimal point, range from 1 to 6, default 2 -
rounding
public int roundingno. of significant digit, range from 1 to 12, default 1 -
negative
public int negativenegative position, 0 - before currency sign (default), 1 - after currency sign, 2 - end of number -
decimalSep
public char decimalSepdecimal point char, default '.' -
thousandSep
public char thousandSepthousand separator, if 'N' means no thousand separator. 1000, default ',' -
leadingZero
public boolean leadingZeroleading zero, 0 or 1
-
-
Constructor Details
-
NumericFormat
public NumericFormat()Create a new numeric format with default values.
-
-
Method Details
-
getCustomCurrency
Get custom multi-character currency symbol Deprecates the old char type currency symbol variable "currencySymbol" -
setCustomCurrency
Set custom multi-character currency symbol Deprecates the old char type currency symbol variable "currencySymbol" -
getFormatType
public int getFormatType()Define quadbase.util.IFormat. Return the type of quadbase.util.IFormat.- Specified by:
getFormatTypein interfaceIFormat- Returns:
- IFormat.NUMERIC
-
format
Define quadbase.util.IFormat. Use the doubleValue() method in java.lang.Number to return a formatted string. If the target object is not an instance of Number, use the default toString() method. -
setDefault
public void setDefault()Set all variables to default value -
setScientifExp
public void setScientifExp(int precision) Set scientific expression- Parameters:
precision- no of decimal point
-
setFormat
public void setFormat(char currSymInit, boolean oneSymPerPageInit, int currencyPosInit, int decimalInit, int roundingInit, int negativeInit, char decimalSepInit, char thousandSepInit, boolean leadingZeroInit) Set Numeric format.- Parameters:
currSymInit- currency symboloneSymPerPageInit- not used, always set to falsecurrencyPosInit- currency position 0-2decimalInit- no. of decimal pointroundingInit- no. of significant digitnegativeInit- negative symbol position 0-2decimalSepInit- decimal point symbolleadingZeroInit- leading zerothoudsandSepInit- thousands separator symbol, 'N' means no thousands separator
-
setFormat
public void setFormat(char currSymInit, boolean oneSymPerPageInit, int currencyPosInit, int decimalInit, int roundingInit, int negativeInit, char decimalSepInit, char thousandSepInit, boolean leadingZeroInit, String customCurrency) Set Numeric format.- Parameters:
currSymInit- currency symboloneSymPerPageInit- not used, always set to falsecurrencyPosInit- currency position 0-2decimalInit- no. of decimal pointroundingInit- no. of significant digitnegativeInit- negative symbol position 0-2decimalSepInit- decimal point symbolleadingZeroInit- leading zerocustomCurrency- custom currency signthoudsandSepInit- thousands separator symbol, 'N' means no thousands separator
-
output
Output the formatted number.- Parameters:
d- number to be formatted- Returns:
- formatted value
-
toString
-