APIdia Launch Partner
Top Description Constructors Methods
java.text.spi

public abstract Class NumberFormatProvider

extends LocaleServiceProvider
Class Inheritance
Known Direct Subclasses
sun.util.locale.provider.NumberFormatProviderImpl, sun.util.locale.provider.SPILocaleProviderAdapter.NumberFormatProviderDelegate
Imports
java.text.NumberFormat, java.util.Locale, java.util.spi.LocaleServiceProvider

An abstract class for service providers that provide concrete implementations of the NumberFormat class.
Since
1.6

Constructor Summary

AccessConstructor and Description
protected
NumberFormatProvider()

Sole constructor.

Method Summary

Modifier and TypeMethod and Description
public NumberFormat

Returns:

a compact number formatter
getCompactNumberInstance
(Locale
the desired locale
locale
,
NumberFormat.Style
the style for formatting a number
formatStyle
)

Returns a new NumberFormat instance which formats a number in its compact form for the specified locale and formatStyle.

public abstract NumberFormat

Returns:

a currency formatter
getCurrencyInstance
(Locale
the desired locale.
locale
)

Returns a new NumberFormat instance which formats monetary values for the specified locale.

public abstract NumberFormat

Returns:

a number format for integer values
getIntegerInstance
(Locale
the desired locale
locale
)

Returns a new NumberFormat instance which formats integer values for the specified locale.

public abstract NumberFormat

Returns:

a general-purpose number formatter
getNumberInstance
(Locale
the desired locale
locale
)

Returns a new general-purpose NumberFormat instance for the specified locale.

public abstract NumberFormat

Returns:

a percent formatter
getPercentInstance
(Locale
the desired locale
locale
)

Returns a new NumberFormat instance which formats percentage values for the specified locale.

Inherited from java.util.spi.LocaleServiceProvider:
getAvailableLocalesisSupportedLocale

Constructor Detail

NumberFormatProviderback to summary
protected NumberFormatProvider()

Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Detail

getCompactNumberInstanceback to summary
public NumberFormat getCompactNumberInstance(Locale locale, NumberFormat.Style formatStyle)

Returns a new NumberFormat instance which formats a number in its compact form for the specified locale and formatStyle.

Implementation Specification

The default implementation of this method throws UnsupportedOperationException. Overriding the implementation of this method returns the compact number formatter instance of the given locale with specified formatStyle.

Parameters
locale:Locale

the desired locale

formatStyle:NumberFormat.Style

the style for formatting a number

Returns:NumberFormat

a compact number formatter

Exceptions
NullPointerException:
if locale or formatStyle is null
IllegalArgumentException:
if locale is not one of the locales returned from getAvailableLocales().
UnsupportedOperationException:
if the implementation does not support this method
Since
12
See Also
java.text.NumberFormat#getCompactNumberInstance(Locale, NumberFormat.Style)
getCurrencyInstanceback to summary
public abstract NumberFormat getCurrencyInstance(Locale locale)

Returns a new NumberFormat instance which formats monetary values for the specified locale.

Parameters
locale:Locale

the desired locale.

Returns:NumberFormat

a currency formatter

Exceptions
NullPointerException:
if locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.text.NumberFormat#getCurrencyInstance(java.util.Locale)
getIntegerInstanceback to summary
public abstract NumberFormat getIntegerInstance(Locale locale)

Returns a new NumberFormat instance which formats integer values for the specified locale. The returned number format is configured to round floating point numbers to the nearest integer using half-even rounding (see HALF_EVEN) for formatting, and to parse only the integer part of an input string (see isParseIntegerOnly).

Parameters
locale:Locale

the desired locale

Returns:NumberFormat

a number format for integer values

Exceptions
NullPointerException:
if locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.text.NumberFormat#getIntegerInstance(java.util.Locale)
getNumberInstanceback to summary
public abstract NumberFormat getNumberInstance(Locale locale)

Returns a new general-purpose NumberFormat instance for the specified locale.

Parameters
locale:Locale

the desired locale

Returns:NumberFormat

a general-purpose number formatter

Exceptions
NullPointerException:
if locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.text.NumberFormat#getNumberInstance(java.util.Locale)
getPercentInstanceback to summary
public abstract NumberFormat getPercentInstance(Locale locale)

Returns a new NumberFormat instance which formats percentage values for the specified locale.

Parameters
locale:Locale

the desired locale

Returns:NumberFormat

a percent formatter

Exceptions
NullPointerException:
if locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.text.NumberFormat#getPercentInstance(java.util.Locale)