Share via


CompactDecimalFormat Class

Definition

Formats numbers in compact (abbreviated) notation, like "1.

[Android.Runtime.Register("android/icu/text/CompactDecimalFormat", ApiSince=24, DoNotGenerateAcw=true)]
public class CompactDecimalFormat : Android.Icu.Text.DecimalFormat
[<Android.Runtime.Register("android/icu/text/CompactDecimalFormat", ApiSince=24, DoNotGenerateAcw=true)>]
type CompactDecimalFormat = class
    inherit DecimalFormat
Inheritance
Attributes

Remarks

Formats numbers in compact (abbreviated) notation, like "1.2K" instead of "1200".

<strong>IMPORTANT:</strong> New users are strongly encouraged to see if NumberFormatter fits their use case. Although not deprecated, this class, CompactDecimalFormat, is provided for backwards compatibility only. <hr>

The CompactDecimalFormat produces abbreviated numbers, suitable for display in environments will limited real estate. For example, 'Hits: 1.2B' instead of 'Hits: 1,200,000,000'. The format will be appropriate for the given language, such as "1,2 Mrd." for German.

For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345), the result will be short for supported languages. However, the result may sometimes exceed 7 characters, such as when there are combining marks or thin characters. In such cases, the visual width in fonts should still be short.

By default, there are 2 significant digits. After creation, if more than three significant digits are set (with setMaximumSignificantDigits), or if a fixed number of digits are set (with setMaximumIntegerDigits or setMaximumFractionDigits), then result may be wider.

The "short" style is also capable of formatting currency amounts, such as "$1.2M" instead of "$1,200,000.00" (English) or "5,3 Mio. €" instead of "5.300.000,00 €" (German). Localized data concerning longer formats is not available yet in the Unicode CLDR. Because of this, attempting to format a currency amount using the "long" style will produce an UnsupportedOperationException.

At this time, negative numbers and parsing are not supported, and will produce an UnsupportedOperationException. Resetting the pattern prefixes or suffixes is not supported; the method calls are ignored.

Note that important methods, like setting the number of decimals, will be moved up from DecimalFormat to NumberFormat.

Java documentation for android.icu.text.CompactDecimalFormat.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

CompactDecimalFormat(IntPtr, JniHandleOwnership)

Fields

Accountingcurrencystyle
Obsolete.

<strong>[icu]</strong> Constant to specify currency style of format which uses currency symbol to represent currency for accounting, for example: "($3.

(Inherited from NumberFormat)
Cashcurrencystyle
Obsolete.

<strong>[icu]</strong> Constant to specify currency cash style of format which uses currency ISO code to represent currency, for example: "NT$3" instead of "NT$3.

(Inherited from NumberFormat)
Currencystyle
Obsolete.

<strong>[icu]</strong> Constant to specify general currency style of format.

(Inherited from NumberFormat)
FractionField
Obsolete.

Field constant used to construct a FieldPosition object.

(Inherited from NumberFormat)
IntegerField
Obsolete.

Field constant used to construct a FieldPosition object.

(Inherited from NumberFormat)
Integerstyle
Obsolete.

<strong>[icu]</strong> Constant to specify a integer number style format.

(Inherited from NumberFormat)
Isocurrencystyle
Obsolete.

<strong>[icu]</strong> Constant to specify currency style of format which uses currency ISO code to represent currency, for example: "USD3.

(Inherited from NumberFormat)
MinimumGroupingDigitsAuto

<strong>[icu]</strong> Constant for #setMinimumGroupingDigits(int) to specify display grouping using the default strategy for all locales.

(Inherited from DecimalFormat)
MinimumGroupingDigitsMin2

<strong>[icu]</strong> Constant for #setMinimumGroupingDigits(int) to specify display grouping using locale defaults, except do not show grouping on values smaller than 10000 (such that there is a minimum of two digits before the first separator).

(Inherited from DecimalFormat)
Numberstyle
Obsolete.

<strong>[icu]</strong> Constant to specify normal number style of format.

(Inherited from NumberFormat)
PadAfterPrefix
Obsolete.

<strong>[icu]</strong> Constant for #getPadPosition() and #setPadPosition(int) to specify pad characters inserted after the prefix.

(Inherited from DecimalFormat)
PadAfterSuffix
Obsolete.

<strong>[icu]</strong> Constant for #getPadPosition() and #setPadPosition(int) to specify pad characters inserted after the suffix.

(Inherited from DecimalFormat)
PadBeforePrefix
Obsolete.

<strong>[icu]</strong> Constant for #getPadPosition() and #setPadPosition(int) to specify pad characters inserted before the prefix.

(Inherited from DecimalFormat)
PadBeforeSuffix
Obsolete.

<strong>[icu]</strong> Constant for #getPadPosition() and #setPadPosition(int) to specify pad characters inserted before the suffix.

(Inherited from DecimalFormat)
Percentstyle
Obsolete.

<strong>[icu]</strong> Constant to specify a style of format to display percent.

(Inherited from NumberFormat)
Pluralcurrencystyle
Obsolete.

<strong>[icu]</strong> Constant to specify currency style of format which uses currency long name with plural format to represent currency, for example, "3.

(Inherited from NumberFormat)
Scientificstyle
Obsolete.

<strong>[icu]</strong> Constant to specify a style of format to display scientific number.

(Inherited from NumberFormat)
Standardcurrencystyle
Obsolete.

<strong>[icu]</strong> Constant to specify currency style of format which uses currency symbol to represent currency, for example "$3.

(Inherited from NumberFormat)

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Currency

Returns the Currency object used to display currency amounts. -or- Sets the Currency object used to display currency amounts.

(Inherited from NumberFormat)
CurrencyPluralInfo

<strong>[icu]</strong> Returns the current instance of CurrencyPluralInfo. -or- <strong>[icu]</strong> Sets a custom instance of CurrencyPluralInfo.

(Inherited from DecimalFormat)
CurrencyUsage (Inherited from DecimalFormat)
DecimalFormatSymbols

Returns a copy of the decimal format symbols used by this formatter. -or- Sets the decimal format symbols used by this formatter.

(Inherited from DecimalFormat)
DecimalPatternMatchRequired

<strong>[icu]</strong> Returns whether the presence of a decimal point must match the pattern. -or- <strong>[icu]</strong> <strong>Parsing:</strong> This method is used to either <em>require</em> or <em>forbid</em> the presence of a decimal point in the string being parsed (disabled by default).

(Inherited from DecimalFormat)
DecimalSeparatorAlwaysShown

Returns whether the decimal separator is shown on integers. -or- <strong>Separators:</strong> Sets whether the decimal separator (a period in <em>en-US</em>) is shown on integers.

(Inherited from DecimalFormat)
ExponentSignAlwaysShown

<strong>[icu]</strong> Returns whether the sign (plus or minus) is always printed in scientific notation. -or- <strong>[icu]</strong> <strong>Scientific Notation:</strong> Sets whether the sign (plus or minus) is always to be shown in the exponent in scientific notation.

(Inherited from DecimalFormat)
FormatWidth

Returns the minimum number of characters in formatted output. -or- <strong>Padding:</strong> Sets the minimum width of the string output by the formatting pipeline.

(Inherited from DecimalFormat)
GroupingSize

Returns the primary grouping size in use. -or- <strong>Grouping:</strong> Sets the primary grouping size (distance between grouping separators) used when formatting large numbers.

(Inherited from DecimalFormat)
GroupingUsed

Returns true if grouping is used in this format. -or- Sets whether or not grouping will be used in this format.

(Inherited from NumberFormat)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
MathContext

<strong>[icu]</strong> Returns the java.math.MathContext being used to round numbers. -or- <strong>[icu]</strong> <strong>Rounding and Digit Limits:</strong> Sets the java.math.MathContext used to round numbers.

(Inherited from DecimalFormat)
MathContextICU

<strong>[icu]</strong> Returns the android.icu.math.MathContext being used to round numbers. -or- <strong>[icu]</strong> <strong>Rounding and Digit Limits:</strong> Overload of #setMathContext for android.icu.math.MathContext.

(Inherited from DecimalFormat)
MaximumFractionDigits

Returns the maximum number of digits allowed in the fraction portion of a number. -or- Sets the maximum number of digits allowed in the fraction portion of a number.

(Inherited from NumberFormat)
MaximumIntegerDigits

Returns the maximum number of digits allowed in the integer portion of a number. -or- Sets the maximum number of digits allowed in the integer portion of a number.

(Inherited from NumberFormat)
MaximumSignificantDigits

<strong>[icu]</strong> Returns the effective maximum number of significant digits displayed. -or- <strong>[icu]</strong> <strong>Rounding and Digit Limits:</strong> Sets the maximum number of significant digits to be displayed.

(Inherited from DecimalFormat)
MinimumExponentDigits

<strong>[icu]</strong> Returns the minimum number of digits printed in the exponent in scientific notation. -or- <strong>[icu]</strong> <strong>Scientific Notation:</strong> Sets the minimum number of digits to be printed in the exponent.

(Inherited from DecimalFormat)
MinimumFractionDigits

Returns the minimum number of digits allowed in the fraction portion of a number. -or- Sets the minimum number of digits allowed in the fraction portion of a number.

(Inherited from NumberFormat)
MinimumGroupingDigits

<strong>[icu]</strong> Returns the minimum number of digits before grouping is triggered. -or- <strong>[icu]</strong> Sets the minimum number of digits that must be before the first grouping separator in order for the grouping separator to be printed.

(Inherited from DecimalFormat)
MinimumIntegerDigits

Returns the minimum number of digits allowed in the integer portion of a number. -or- Sets the minimum number of digits allowed in the integer portion of a number.

(Inherited from NumberFormat)
MinimumSignificantDigits

<strong>[icu]</strong> Returns the effective minimum number of significant digits displayed. -or- <strong>[icu]</strong> <strong>Rounding and Digit Limits:</strong> Sets the minimum number of significant digits to be displayed.

(Inherited from DecimalFormat)
Multiplier

Returns the multiplier being applied to numbers before they are formatted. -or- Sets a number that will be used to multiply all numbers prior to formatting.

(Inherited from DecimalFormat)
NegativePrefix

<strong>Affixes:</strong> Gets the negative prefix string currently being used to format numbers. -or- <strong>Affixes:</strong> Sets the string to prepend to negative numbers.

(Inherited from DecimalFormat)
NegativeSuffix

<strong>Affixes:</strong> Gets the negative suffix string currently being used to format numbers. -or- <strong>Affixes:</strong> Sets the string to append to negative numbers.

(Inherited from DecimalFormat)
PadCharacter

<strong>[icu]</strong> Returns the character used for padding. -or- <strong>[icu]</strong> <strong>Padding:</strong> Sets the character used to pad numbers that are narrower than the width specified in #setFormatWidth.

(Inherited from DecimalFormat)
PadPosition

<strong>[icu]</strong> Returns the position used for padding. -or- <strong>[icu]</strong> <strong>Padding:</strong> Sets the position where to insert the pad character when narrower than the width specified in #setFormatWidth.

(Inherited from DecimalFormat)
ParseBigDecimal

Returns whether #parse will always return a BigDecimal. -or- Whether to make #parse prefer returning a android.icu.math.BigDecimal when possible.

(Inherited from DecimalFormat)
ParseCaseSensitive

<strong>[icu]</strong> Returns whether to force case (uppercase/lowercase) to match when parsing. -or- <strong>[icu]</strong> Specifies whether parsing should require cases to match in affixes, exponent separators, and currency codes.

(Inherited from DecimalFormat)
ParseIntegerOnly

Returns true if this format will parse numbers as integers only. -or- Sets whether to ignore the fraction part of a number when parsing (defaults to false).

(Inherited from NumberFormat)
ParseMaxDigits

Always returns 1000, the default prior to ICU 59. -or- This member is deprecated.

(Inherited from DecimalFormat)
ParseNoExponent

<strong>[icu]</strong> Returns whether to ignore exponents when parsing. -or- <strong>[icu]</strong> Specifies whether to stop parsing when an exponent separator is encountered.

(Inherited from DecimalFormat)
ParseStrict

<strong>[icu]</strong> Returns whether strict parsing is in effect. -or- <strong>[icu]</strong> Sets whether strict parsing is in effect.

(Inherited from NumberFormat)
PeerReference (Inherited from Object)
PositivePrefix

<strong>Affixes:</strong> Gets the positive prefix string currently being used to format numbers. -or- <strong>Affixes:</strong> Sets the string to prepend to positive numbers.

(Inherited from DecimalFormat)
PositiveSuffix

<strong>Affixes:</strong> Gets the positive suffix string currently being used to format numbers. -or- <strong>Affixes:</strong> Sets the string to append to positive numbers.

(Inherited from DecimalFormat)
RoundingIncrement

<strong>[icu]</strong> Returns the increment to which numbers are being rounded. -or- <strong>[icu]</strong> <strong>Rounding and Digit Limits:</strong> Sets an increment, or interval, to which numbers are rounded.

(Inherited from DecimalFormat)
RoundingMode

Returns the rounding mode used in this NumberFormat. -or- Set the rounding mode used in this NumberFormat.

(Inherited from NumberFormat)
ScientificNotation

<strong>[icu]</strong> Returns whether scientific (exponential) notation is enabled on this formatter. -or- <strong>[icu]</strong> <strong>Scientific Notation:</strong> Sets whether this formatter should print in scientific (exponential) notation.

(Inherited from DecimalFormat)
SecondaryGroupingSize

<strong>[icu]</strong> Returns the secondary grouping size in use. -or- <strong>[icu]</strong> <strong>Grouping:</strong> Sets the secondary grouping size (distance between grouping separators after the first separator) used when formatting large numbers.

(Inherited from DecimalFormat)
SignAlwaysShown

<strong>[icu]</strong> Returns whether the sign is being shown on positive numbers. -or- Sets whether to always shown the plus sign ('+' in <em>en</em>) on positive numbers.

(Inherited from DecimalFormat)
ThresholdClass
ThresholdType

Methods

ApplyLocalizedPattern(String)

Converts the given string to standard notation and then parses it using #applyPattern.

(Inherited from DecimalFormat)
ApplyPattern(String)

Parses the given pattern string and overwrites the settings specified in the pattern string.

(Inherited from DecimalFormat)
AreSignificantDigitsUsed()

<strong>[icu]</strong> Returns whether significant digits are being used in rounding.

(Inherited from DecimalFormat)
Clone()

Creates and returns a copy of this object.

(Inherited from _Format)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Format(BigDecimal, StringBuffer, FieldPosition)

To be added

(Inherited from DecimalFormat)
Format(BigDecimal, StringBuffer, FieldPosition)

To be added

(Inherited from DecimalFormat)
Format(BigDecimal)

Convenience method to format a BigDecimal.

(Inherited from NumberFormat)
Format(BigDecimal)

<strong>[icu]</strong> Convenience method to format an ICU BigDecimal.

(Inherited from NumberFormat)
Format(BigInteger, StringBuffer, FieldPosition)

To be added

(Inherited from DecimalFormat)
Format(BigInteger)

<strong>[icu]</strong> Convenience method to format a BigInteger.

(Inherited from NumberFormat)
Format(CurrencyAmount, StringBuffer, FieldPosition)

<strong>[icu]</strong> Formats a CurrencyAmount.

(Inherited from NumberFormat)
Format(CurrencyAmount)

<strong>[icu]</strong> Convenience method to format a CurrencyAmount.

(Inherited from NumberFormat)
Format(Double, StringBuffer, FieldPosition)

To be added

(Inherited from DecimalFormat)
Format(Double)

Specialization of format.

(Inherited from NumberFormat)
Format(Int64, StringBuffer, FieldPosition)

To be added

(Inherited from DecimalFormat)
Format(Int64)

Specialization of format.

(Inherited from NumberFormat)
Format(Object, StringBuffer, FieldPosition)

Formats a number and appends the resulting text to the given string buffer.

(Inherited from NumberFormat)
Format(Object)

Formats an object to produce a string.

(Inherited from _Format)
FormatToCharacterIterator(Object)

Formats an Object producing an AttributedCharacterIterator.

(Inherited from _Format)
GetContext(DisplayContext+Type) (Inherited from NumberFormat)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetInstance(Locale, CompactDecimalFormat+CompactStyle)
GetInstance(ULocale, CompactDecimalFormat+CompactStyle)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Parse(String, ParsePosition)

To be added

(Inherited from DecimalFormat)
Parse(String)

Parses text from the beginning of the given string to produce a number.

(Inherited from NumberFormat)
ParseCurrency(ICharSequence, ParsePosition)

Parses text from the given string as a CurrencyAmount.

(Inherited from NumberFormat)
ParseCurrency(String, ParsePosition)

Parses text from the given string as a CurrencyAmount.

(Inherited from NumberFormat)
ParseObject(String, ParsePosition)

Parses text from a string to produce a number.

(Inherited from NumberFormat)
ParseObject(String)

Parses text from the beginning of the given string to produce an object.

(Inherited from _Format)
SetContext(DisplayContext)

<strong>[icu]</strong> Set a particular DisplayContext value in the formatter, such as CAPITALIZATION_FOR_STANDALONE.

(Inherited from NumberFormat)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetRoundingIncrement(BigDecimal)

<strong>[icu]</strong> <strong>Rounding and Digit Limits:</strong> Overload of #setRoundingIncrement(java.math.BigDecimal).

(Inherited from DecimalFormat)
SetRoundingIncrement(Double)

<strong>[icu]</strong> <strong>Rounding and Digit Limits:</strong> Overload of #setRoundingIncrement(java.math.BigDecimal).

(Inherited from DecimalFormat)
SetSignificantDigitsUsed(Boolean)

<strong>[icu]</strong> <strong>Rounding and Digit Limits:</strong> Sets whether significant digits are to be used in rounding.

(Inherited from DecimalFormat)
ToArray<T>() (Inherited from Object)
ToLocalizedPattern()

Calls #toPattern and converts the string to localized notation.

(Inherited from DecimalFormat)
ToPattern()

Serializes this formatter object to a decimal format pattern string.

(Inherited from DecimalFormat)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to