All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.text.NumberFormat

java.lang.Object
   |
   +----java.text.Format
           |
           +----java.text.NumberFormat

public class NumberFormat
extends Format
implements Cloneable
Abstract base class for all number formats. Provides interface for formatting and parsing a number. Also provides methods for determining which locales have number formats, and what their names are.

See Also:
DecimalFormat, ChoiceFormat

Variable Index

 o DECIMAL_FIELD
Decimal field is the alignment field.
 o DENOMINATOR_FIELD
Denominator field is the alignment field.
 o EXPONENT_FIELD
Exponent field is the alignment field.
 o INTEGER_FIELD
Integer field is the alignment field.
 o NUMBERATOR_FIELD
Numerator field is the alignment field.

Constructor Index

 o NumberFormat()

Method Index

 o clone()
Overrides Cloneable
 o format(double)
Specialization of format.
 o format(double, StringBuffer, FormatStatus)
Specialization of format.
 o format(long)
Specialization of format.
 o format(long, StringBuffer, FormatStatus)
Specialization of format.
 o format(Object, StringBuffer, FormatStatus)
Formats an object to produce a string.
 o getAvailableLocales()
Get the set of Locales for which NumberFormats are installed
 o getCurrencySymbol()
Get the currency symbol of the current locale.
 o getCurrencySymbol(Locale)
Get the currency symbol of the desired locale.
 o getDefault()
Gets a general-purpose number format for the current default locale
 o getDefault(Locale)
Gets a general-purpose number format for the specified locale
 o getDefaultCurrency()
Gets a currency format for the current default locale
 o getDefaultCurrency(Locale)
Gets a currency format for the specified locale
 o getDefaultPercent()
Gets a percentage format for the current default locale
 o getDefaultPercent(Locale)
Gets a percentage format for the specified locale
 o getDisplayName(Locale)
Get name of the object for the desired Locale, in the langauge of the default locale.
 o getDisplayName(Locale, Locale)
Get name of the object for the desired Locale, in the desired langauge.
 o getIntlCurrencySymbol()
Get the international currency symbol of the current locale.
 o getIntlCurrencySymbol(Locale)
Get the international currency symbol of the desired locale.
 o getMaximumDecimalCount()
Allows you to get the maximum and minimum digit counts for the decimal portion.
 o getMaximumIntegerCount()
Allows you to get the maximum digit count for the integer portion.
 o getMinimumDecimalCount()
Allows you to get the maximum and minimum digit counts for the decimal portion.
 o getMinimumIntegerCount()
Allows you to get the minimum digit count for the integer portion.
 o isDecimalUsedWithInteger()
Allows you to get the behavior of the decimal separator with integers.
 o isIntegerOnly()
Gets flag that indicates that it stops at a decimal point (or equivalent; e.g.
 o isThousandsUsed()
Allows you to get the behavior of the thousands separator.
 o parse(String)
Convenience method.
 o parse(String, ParseStatus)
Returns a Long if possible (e.g.
 o parseObject(String, ParseStatus)
Parses a string to produce an object.
 o setDecimalUsedWithInteger(boolean)
Allows you to set the behavior of the decimal separator with integers.
 o setIntegerOnly(boolean)
Sets flag that indicates that it stops at a decimal point (or equivalent; e.g.
 o setMaximumDecimalCount(int)
Allows you to set the maximum and minimum digit counts for the decimal portion.
 o setMaximumIntegerCount(int)
Allows you to set the maximum digit count for the integer portion.
 o setMinimumDecimalCount(int)
Allows you to set the maximum and minimum digit counts for the decimal portion.
 o setMinimumIntegerCount(int)
Allows you to set the minimum digit count for the integer portion.
 o setThousandsUsed(boolean)
Allows you to set the behavior of the thousands separator.

Variables

 o INTEGER_FIELD
  public final static byte INTEGER_FIELD
Integer field is the alignment field.

 o DECIMAL_FIELD
  public final static byte DECIMAL_FIELD
Decimal field is the alignment field.

 o NUMBERATOR_FIELD
  public final static byte NUMBERATOR_FIELD
Numerator field is the alignment field.

 o DENOMINATOR_FIELD
  public final static byte DENOMINATOR_FIELD
Denominator field is the alignment field.

 o EXPONENT_FIELD
  public final static byte EXPONENT_FIELD
Exponent field is the alignment field.

Constructors

 o NumberFormat
  public NumberFormat()

Methods

 o format
  public final StringBuffer format(Object number,
                                   StringBuffer toAppendTo,
                                   FormatStatus status)
Formats an object to produce a string.

Overrides:
format in class Format
 o parseObject
  public final Object parseObject(String source,
                                  ParseStatus status)
Parses a string to produce an object.

Overrides:
parseObject in class Format
 o format
  public final String format(double number)
Specialization of format.

See Also:
format
 o format
  public final String format(long number)
Specialization of format.

See Also:
format
 o format
  public abstract StringBuffer format(double number,
                                      StringBuffer toAppendTo,
                                      FormatStatus status)
Specialization of format.

See Also:
format
 o format
  public abstract StringBuffer format(long number,
                                      StringBuffer toAppendTo,
                                      FormatStatus status)
Specialization of format.

See Also:
format
 o parse
  public abstract Number parse(String text,
                               ParseStatus status)
Returns a Long if possible (e.g. within range, and with no decimals), otherwise a Double. If IntegerOnly is set, will stop at a decimal point (or equivalent; e.g. for rational numbers "1 2/3", will stop after the 1). Does not throw an exception; if no object can be parsed, startAt is unchanged!

See Also:
isIntegerOnly, parseObject
 o parse
  public Number parse(String text) throws FormatException
Convenience method.

See Also:
format
 o isIntegerOnly
  public boolean isIntegerOnly()
Gets flag that indicates that it stops at a decimal point (or equivalent; e.g. for rational numbers "1 2/3", will stop after the 1 if integerOnly; continue to parse the 2/3 if !integerOnly).

 o setIntegerOnly
  public void setIntegerOnly(boolean value)
Sets flag that indicates that it stops at a decimal point (or equivalent; e.g. for rational numbers "1 2/3", will stop after the 1 if integerOnly; continue to parse the 2/3 if !integerOnly).

 o getDefault
  public final static synchronized NumberFormat getDefault()
Gets a general-purpose number format for the current default locale

Returns:
general-purpose number format
 o getDefaultCurrency
  public final static synchronized NumberFormat getDefaultCurrency()
Gets a currency format for the current default locale

Returns:
currency format
 o getDefaultPercent
  public final static synchronized NumberFormat getDefaultPercent()
Gets a percentage format for the current default locale

Returns:
percentage number format
 o getDefault
  public static synchronized NumberFormat getDefault(Locale inLocale)
Gets a general-purpose number format for the specified locale

Returns:
general-purpose number format
 o getDefaultCurrency
  public static synchronized NumberFormat getDefaultCurrency(Locale inLocale)
Gets a currency format for the specified locale

Returns:
currency format
 o getDefaultPercent
  public static synchronized NumberFormat getDefaultPercent(Locale inLocale)
Gets a percentage format for the specified locale

Returns:
percentage number format
 o getAvailableLocales
  public static synchronized Locale[] getAvailableLocales()
Get the set of Locales for which NumberFormats are installed

Returns:
available locales
 o getDisplayName
  public static synchronized String getDisplayName(Locale objectLocale,
                                                   Locale displayLocale)
Get name of the object for the desired Locale, in the desired langauge.

Parameters:
objectLocale - must be from getAvailableLocales.
displayLocale - specifies the desired locale for output. Uses best match.
Returns:
user-displayable name
Throws: throws
MissingResourceException if objectLocale is not from must be from getAvailableLocales
See Also:
ResourceBundle
 o getDisplayName
  public final static String getDisplayName(Locale objectLocale)
Get name of the object for the desired Locale, in the langauge of the default locale.

Parameters:
objectLocale - must be from getAvailableLocales.
Returns:
user-displayable name
Throws: throws
MissingResourceException if objectLocale is not from must be from getAvailableLocales
See Also:
ResourceBundle
 o getCurrencySymbol
  public final String getCurrencySymbol()
Get the currency symbol of the current locale.

Returns:
the currency symbol
 o getCurrencySymbol
  public final String getCurrencySymbol(Locale loc)
Get the currency symbol of the desired locale.

Parameters:
loc - the desired locale
Returns:
the currency symbol
 o getIntlCurrencySymbol
  public final String getIntlCurrencySymbol()
Get the international currency symbol of the current locale.

Returns:
the international currency symbol
 o getIntlCurrencySymbol
  public final String getIntlCurrencySymbol(Locale loc)
Get the international currency symbol of the desired locale.

Parameters:
loc - the desired locale
Returns:
the international currency symbol
 o clone
  public Object clone()
Overrides Cloneable

Overrides:
clone in class Object
 o isThousandsUsed
  public boolean isThousandsUsed()
Allows you to get the behavior of the thousands separator. Thousands ON is ignored if there are fewer than thousandsInterval integer digits.

Example: Thousands ON: 12345 -> 12,345; OFF: 12345 -> 12345

 o setThousandsUsed
  public void setThousandsUsed(boolean newValue)
Allows you to set the behavior of the thousands separator. Thousands ON is ignored if there are fewer than thousandsInterval integer digits.

Example: Thousands ON: 12345 -> 12,345; OFF: 12345 -> 12345

 o isDecimalUsedWithInteger
  public boolean isDecimalUsedWithInteger()
Allows you to get the behavior of the decimal separator with integers. (The decimal separator will always appear with decimals.)

Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345

 o setDecimalUsedWithInteger
  public void setDecimalUsedWithInteger(boolean newValue)
Allows you to set the behavior of the decimal separator with integers. (The decimal separator will always appear with decimals.)

Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345

 o getMaximumIntegerCount
  public int getMaximumIntegerCount()
Allows you to get the maximum digit count for the integer portion.

Example: with different values, 123 -> 123; 00,123;

 o setMaximumIntegerCount
  public void setMaximumIntegerCount(int newValue)
Allows you to set the maximum digit count for the integer portion.

Example: with different values, 123 -> 123; 00,123;

 o getMinimumIntegerCount
  public int getMinimumIntegerCount()
Allows you to get the minimum digit count for the integer portion.

Example: with different values, 123 -> 123; 00,123;

 o setMinimumIntegerCount
  public void setMinimumIntegerCount(int newValue)
Allows you to set the minimum digit count for the integer portion.

Example: with different values, 123 -> 123; 00,123;

 o getMaximumDecimalCount
  public int getMaximumDecimalCount()
Allows you to get the maximum and minimum digit counts for the decimal portion.

Example: with different values, 1.246 -> 1.25, 1.246000

 o setMaximumDecimalCount
  public void setMaximumDecimalCount(int newValue)
Allows you to set the maximum and minimum digit counts for the decimal portion.

Example: with different values, 1.246 -> 1.25, 1.246000

 o getMinimumDecimalCount
  public int getMinimumDecimalCount()
Allows you to get the maximum and minimum digit counts for the decimal portion.

Example: with different values, 1.246 -> 1.25, 1.246000

 o setMinimumDecimalCount
  public void setMinimumDecimalCount(int newValue)
Allows you to set the maximum and minimum digit counts for the decimal portion.

Example: with different values, 1.246 -> 1.25, 1.246000


All Packages  Class Hierarchy  This Package  Previous  Next  Index