Class BtcFixedFormat
- All Implemented Interfaces:
Serializable
,Cloneable
This class, a concrete extension of BtcFormat
, is distinguished in that each
instance formats and by-default parses all Bitcoin monetary values in units of a single
denomination that is specified at the time that instance is constructed.
By default, neither currency codes nor symbols are included in formatted values as
output, nor recognized in parsed values as input. The can be overridden by applying a
custom pattern using either the BtcFormat.Builder.localizedPattern
or
BtcFormat.Builder.localizedPattern
methods, as described in the documentation for
the BtcFormat.Builder
class.
A more detailed explanation, including examples, is in the documentation for the
BtcFormat
class, and further information beyond that is in the documentation for the
Format
class, from which this class descends.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bitcoinj.utils.BtcFormat
BtcFormat.Builder
Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int[]
A constant specifying the use of as many optional groups of two decimal places in the fraction part of a formatted number as are useful for expressing precision.static final int[]
A constant specifying the use of as many optional decimal places in the fraction part of a formatted number as are useful for expressing precision.static final int[]
A constant specifying the use of as many optional groups of three decimal places in the fraction part of a formatted number as are useful for expressing precision.Fields inherited from class org.bitcoinj.utils.BtcFormat
COIN_SCALE, COIN_SYMBOL_ALT, decimalGroups, MICROCOIN_SCALE, MILLICOIN_SCALE, minimumFractionDigits, numberFormat
-
Constructor Summary
ModifierConstructorDescriptionprotected
BtcFixedFormat
(Locale locale, int scale, int minDecimals, List<Integer> groups) Constructor -
Method Summary
Modifier and TypeMethodDescriptioncode()
Return the currency code that identifies the units in which values formatted and (by-default) parsed by this instance are denominated.boolean
Return true if the given object is equivalent to this one.int[]
Return the fractional decimal-placing used when formatting.int
hashCode()
Return a hash code value for this instance.int
scale()
Return the decimal-place shift for this object's fixed unit-denomination.protected int
scale
(BigInteger satoshis, int fractionPlaces) Return the decimal-place shift for this object's unit-denomination.symbol()
Return the currency symbol that identifies the units in which values formatted by this instance are denominated.toString()
Returns a brief description of this formatter.Methods inherited from class org.bitcoinj.utils.BtcFormat
builder, coinCode, coinSymbol, format, format, format, formatToCharacterIterator, getAvailableLocales, getCodeInstance, getCodeInstance, getCodeInstance, getCodeInstance, getCoinInstance, getCoinInstance, getCoinInstance, getCoinInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getMicroInstance, getMicroInstance, getMicroInstance, getMicroInstance, getMilliInstance, getMilliInstance, getMilliInstance, getMilliInstance, getSymbolInstance, getSymbolInstance, getSymbolInstance, getSymbolInstance, negify, parse, parse, parseObject, pattern, prefixCode, prefixSymbol, prefixUnitsIndicator, symbols
Methods inherited from class java.text.Format
clone, format, parseObject
-
Field Details
-
REPEATING_PLACES
public static final int[] REPEATING_PLACESA constant specifying the use of as many optional decimal places in the fraction part of a formatted number as are useful for expressing precision. This value can be passed as the final argument to a factory method orBtcFormat.format(Object, int, int...)
. -
REPEATING_DOUBLETS
public static final int[] REPEATING_DOUBLETSA constant specifying the use of as many optional groups of two decimal places in the fraction part of a formatted number as are useful for expressing precision. This value can be passed as the final argument to a factory method orBtcFormat.format(Object, int, int...)
. -
REPEATING_TRIPLETS
public static final int[] REPEATING_TRIPLETSA constant specifying the use of as many optional groups of three decimal places in the fraction part of a formatted number as are useful for expressing precision. This value can be passed as the final argument to a factory method orBtcFormat.format(Object, int, int...)
.
-
-
Constructor Details
-
BtcFixedFormat
Constructor
-
-
Method Details
-
scale
Return the decimal-place shift for this object's unit-denomination. For example, if the denomination is millibitcoins, this method will return the value3
. As a side-effect, prefixes the currency signs of the underlying NumberFormat object. This method is invoked by the superclass when formatting. The arguments are ignored because the denomination is fixed regardless of the value being formatted.- Specified by:
scale
in classBtcFormat
- Parameters:
satoshis
- The number of satoshis having the value for which the shift is calculatedfractionPlaces
- The number of decimal places available for displaying the fractional part of the denominated value- Returns:
- The size of the shift in increasingly-precise decimal places
-
scale
public int scale()Return the decimal-place shift for this object's fixed unit-denomination. For example, if the denomination is millibitcoins, this method will return the value3
. -
code
Return the currency code that identifies the units in which values formatted and (by-default) parsed by this instance are denominated. For example, if the formatter's denomination is millibitcoins, then this method will return"mBTC"
, assuming the default base currency-code is not overridden using aBtcFormat.Builder
. -
symbol
Return the currency symbol that identifies the units in which values formatted by this instance are denominated. For example, when invoked on an instance denominated in millibitcoins, this method by default returns"₥฿"
, depending on the locale. -
fractionPlaceGroups
public int[] fractionPlaceGroups()Return the fractional decimal-placing used when formatting. This method returns anint
array. The value of the first element is the minimum number of decimal places to be used in all cases, limited to a precision of satoshis. The value of each successive element is the size of an optional place-group that will be applied, possibly partially, if useful for expressing precision. The actual size of each group is limited to, and may be reduced to the limit of, a precision of no smaller than satoshis. -
equals
Return true if the given object is equivalent to this one. Formatters for different locales will never be equal, even if they behave identically. -
hashCode
public int hashCode()Return a hash code value for this instance. -
toString
Returns a brief description of this formatter. The exact details of the representation are unspecified and subject to change, but will include some representation of the formatting/parsing pattern and the fractional decimal place grouping.
-