Class OceanusDecimalFormatter
java.lang.Object
io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimalFormatter
Presentation methods for decimals in a particular locale.
- Author:
- Tony Washer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charThe Blank character.static final charThe Group character.static final charThe Minus character.static final charThe Zero character.protected static final intThe Buffer length for building decimal strings.(package private) static final OceanusDecimalLocaleThe locale.protected static final StringThe Currency separator.static final StringThe Decimal character. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear accounting mode.formatDecimal(OceanusDecimal pDecimal) Format Decimal value.formatInteger(Integer pValue) Format Integer value.formatLong(Long pValue) Format Long value.formatMoney(OceanusMoney pMoney) Format Money value.formatPrice(OceanusPrice pPrice) Format Price value.formatRate(OceanusRate pRate) Format Rate value.formatRatePerMille(OceanusRate pRate) Format Rate value.formatRatio(OceanusRatio pRatio) Format Ratio value.formatShort(Short pValue) Format Short value.formatUnits(OceanusUnits pUnits) Format Units value.voidsetAccountingWidth(int pWidth) Set accounting width.final voidSet the locale.toCurrencyString(OceanusMoney pValue) Format a money value with currency code, into a locale independent format.protected static StringtoString(OceanusDecimal pValue) Format a decimal value without reference to locale.
-
Field Details
-
INITIAL_BUFLEN
protected static final int INITIAL_BUFLENThe Buffer length for building decimal strings.- See Also:
-
CHAR_BLANK
public static final char CHAR_BLANKThe Blank character.- See Also:
-
CHAR_ZERO
public static final char CHAR_ZEROThe Zero character.- See Also:
-
CHAR_MINUS
public static final char CHAR_MINUSThe Minus character.- See Also:
-
CHAR_GROUP
public static final char CHAR_GROUPThe Group character.- See Also:
-
STR_DEC
The Decimal character.- See Also:
-
STR_CURRSEP
The Currency separator.- See Also:
-
LOCALE_DEFAULT
The locale.
-
-
Constructor Details
-
OceanusDecimalFormatter
public OceanusDecimalFormatter()Constructor. -
OceanusDecimalFormatter
Constructor.- Parameters:
pLocale- the locale
-
-
Method Details
-
setLocale
Set the locale.- Parameters:
pLocale- the locale
-
setAccountingWidth
public void setAccountingWidth(int pWidth) Set accounting width.- Parameters:
pWidth- the accounting width to use
-
clearAccounting
public void clearAccounting()Clear accounting mode. -
toString
Format a decimal value without reference to locale.- Parameters:
pValue- the value to format- Returns:
- the formatted value
-
toCurrencyString
Format a money value with currency code, into a locale independent format.- Parameters:
pValue- the value to format- Returns:
- the formatted value
-
formatMoney
Format Money value.- Parameters:
pMoney- the value to format- Returns:
- the formatted value
-
formatPrice
Format Price value.- Parameters:
pPrice- the value to format- Returns:
- the formatted value
-
formatRate
Format Rate value.- Parameters:
pRate- the value to format- Returns:
- the formatted value
-
formatRatePerMille
Format Rate value.- Parameters:
pRate- the value to format- Returns:
- the formatted value
-
formatUnits
Format Units value.- Parameters:
pUnits- the value to format- Returns:
- the formatted value
-
formatRatio
Format Ratio value.- Parameters:
pRatio- the value to format- Returns:
- the formatted value
-
formatDecimal
Format Decimal value.- Parameters:
pDecimal- the value to format- Returns:
- the formatted value
-
formatLong
Format Long value.- Parameters:
pValue- the value to format- Returns:
- the formatted value
-
formatInteger
Format Integer value.- Parameters:
pValue- the value to format- Returns:
- the formatted value
-
formatShort
Format Short value.- Parameters:
pValue- the value to format- Returns:
- the formatted value
-