Package com.portal.common
Class PCurrencyFormatter
java.lang.Object
java.text.Format
java.text.NumberFormat
java.text.DecimalFormat
com.portal.common.PCurrencyFormatter
- All Implemented Interfaces:
Serializable
,Cloneable
PCurrencyFormatter
is a concrete subclass of
DecimalFormat
that formats currency numbers based on currency
instead of default locale of the system.
There is no public constructor for PCurrencyFormatter
.
To obtain a PCurrencyFormatter
for a specific currency,
call getInstance(int currencyID)
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.NumberFormat
NumberFormat.Field, NumberFormat.Style
-
Field Summary
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
-
Method Summary
Modifier and TypeMethodDescriptionstatic PCurrencyFormatter
getInstance
(int currencyID) Gets an instance of PCurrencyFormatter for a specific currency ID.static int
getRoundingMethod
(int currencyID) Gets the rounding method for a specific currency defined in the currency resource in beid configuration object stored at Portal server.static boolean
isCurrencyID
(int currencyID) Checks if the currency ID is a valid ISO currency ID that is recognized by Portal.static void
setContext
(PortalContext connection) Sets the PortalContext.Methods inherited from class java.text.DecimalFormat
applyLocalizedPattern, applyPattern, clone, equals, format, format, format, formatToCharacterIterator, getCurrency, getDecimalFormatSymbols, getGroupingSize, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getMultiplier, getNegativePrefix, getNegativeSuffix, getPositivePrefix, getPositiveSuffix, getRoundingMode, hashCode, isDecimalSeparatorAlwaysShown, isParseBigDecimal, parse, setCurrency, setDecimalFormatSymbols, setDecimalSeparatorAlwaysShown, setGroupingSize, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setMultiplier, setNegativePrefix, setNegativeSuffix, setParseBigDecimal, setPositivePrefix, setPositiveSuffix, setRoundingMode, toLocalizedPattern, toPattern
Methods inherited from class java.text.NumberFormat
format, format, getAvailableLocales, getCompactNumberInstance, getCompactNumberInstance, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setParseIntegerOnly
Methods inherited from class java.text.Format
format, parseObject
-
Method Details
-
setContext
Sets the PortalContext. You only need to call it once during the whole life span of the application. This is usually called in the initialization of an client application. If the client tool is not connected to Portal server and you don't call the setContext(). The Currency formatter will have the default behaviors that are defined by the CurrencyFormatter.properties file.- Parameters:
connection
- A PortalContext object.
-
getRoundingMethod
public static int getRoundingMethod(int currencyID) Gets the rounding method for a specific currency defined in the currency resource in beid configuration object stored at Portal server.- Parameters:
currencyID
- the currency ID- Returns:
- the rounding method defined in beid configuration object. If
setContext() has not been called to set the connection, returns -1.
-
isCurrencyID
public static boolean isCurrencyID(int currencyID) Checks if the currency ID is a valid ISO currency ID that is recognized by Portal.- Parameters:
currencyID
- the currency ID to evaluate.- Returns:
- Return true if the ID is a valid ISO currency, otherwise return false.
-
getInstance
Gets an instance of PCurrencyFormatter for a specific currency ID.- Parameters:
currencyID
- The currency ID.- Returns:
- an instance of PCurrencyFormatter for the currency ID.
-