public final class BtcAutoFormat extends BtcFormat
This class, a concrete extension of BtcFormat
, is distinguished by its
accommodation of multiple denominational units as follows:
When formatting Bitcoin monetary values, an instance of this class automatically adjusts the denominational units in which it represents a given value so as to minimize the number of consecutive zeros in the number that is displayed, and includes either a currency code or symbol in the formatted value to indicate which denomination was chosen.
When parsing String
representations of Bitcoin monetary values, instances of
this class automatically recognize units indicators consisting of currency codes and
symbols, including including those containing currency or metric prefixes such as
"ยข"
or "c"
to indicate hundredths, and interpret each number being
parsed in accordance with the recognized denominational units.
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.
Format
,
NumberFormat
,
DecimalFormat
,
DecimalFormatSymbols
,
Coin
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
BtcAutoFormat.Style
Enum for specifying the style of currency indicators thas are used
when formatting, ether codes or symbols.
|
BtcFormat.Builder
Format.Field
COIN_SCALE, COIN_SYMBOL_ALT, decimalGroups, MICROCOIN_SCALE, MILLICOIN_SCALE, minimumFractionDigits, numberFormat
Modifier | Constructor and Description |
---|---|
protected |
BtcAutoFormat(Locale locale,
BtcAutoFormat.Style style,
int fractionPlaces)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Return true if the other instance is equivalent to this one.
|
int |
fractionPlaces()
Return the number of decimal places in the fraction part of numbers formatted by this
instance.
|
protected int |
scale()
Returns the
int value indicating coin denomination. |
protected int |
scale(BigInteger satoshis,
int fractionPlaces)
Calculate the appropriate denomination for the given Bitcoin monetary value.
|
String |
toString()
Return a brief description of this formatter.
|
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, hashCode, negify, parse, parse, parseObject, pattern, prefixCode, prefixSymbol, prefixUnitsIndicator, symbols
clone, format, parseObject
protected BtcAutoFormat(Locale locale, BtcAutoFormat.Style style, int fractionPlaces)
protected int scale(BigInteger satoshis, int fractionPlaces)
As a side-effect, this sets the units indicators of the underlying NumberFormat object. Only invoke this from a synchronized method, and be sure to put the DecimalFormatSymbols back to its proper state, otherwise immutability, equals() and hashCode() fail.
scale
in class BtcFormat
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 valueprotected int scale()
int
value indicating coin denomination. This is what causes
the number in a parsed value that lacks a units indicator to be interpreted as a quantity
of bitcoins.public int fractionPlaces()
public boolean equals(Object o)
Copyright © 2016. All rights reserved.