Class BtcFixedFormat

All Implemented Interfaces:
Serializable, Cloneable

public final class BtcFixedFormat extends BtcFormat

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:
  • Field Details

    • REPEATING_PLACES

      public static final int[] REPEATING_PLACES
      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. This value can be passed as the final argument to a factory method or BtcFormat.format(Object, int, int...).
    • REPEATING_DOUBLETS

      public static final int[] REPEATING_DOUBLETS
      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. This value can be passed as the final argument to a factory method or BtcFormat.format(Object, int, int...).
    • REPEATING_TRIPLETS

      public static final int[] REPEATING_TRIPLETS
      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. This value can be passed as the final argument to a factory method or BtcFormat.format(Object, int, int...).
  • Constructor Details

    • BtcFixedFormat

      protected BtcFixedFormat(Locale locale, int scale, int minDecimals, List<Integer> groups)
      Constructor
  • Method Details

    • scale

      protected int scale(BigInteger satoshis, int fractionPlaces)
      Return the decimal-place shift for this object's unit-denomination. For example, if the denomination is millibitcoins, this method will return the value 3. 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 class BtcFormat
      Parameters:
      satoshis - The number of satoshis having the value for which the shift is calculated
      fractionPlaces - 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 value 3.
      Specified by:
      scale in class BtcFormat
    • code

      public String 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 a BtcFormat.Builder.
    • symbol

      public String 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 an int 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

      public boolean equals(Object o)
      Return true if the given object is equivalent to this one. Formatters for different locales will never be equal, even if they behave identically.
      Overrides:
      equals in class BtcFormat
    • hashCode

      public int hashCode()
      Return a hash code value for this instance.
      Overrides:
      hashCode in class BtcFormat
      See Also:
    • toString

      public String 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.
      Overrides:
      toString in class Object