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
-
DECIMAL_FIELD
- Decimal field is the alignment field.
-
DENOMINATOR_FIELD
- Denominator field is the alignment field.
-
EXPONENT_FIELD
- Exponent field is the alignment field.
-
INTEGER_FIELD
- Integer field is the alignment field.
-
NUMBERATOR_FIELD
- Numerator field is the alignment field.
-
NumberFormat()
-
-
clone()
- Overrides Cloneable
-
format(double)
- Specialization of format.
-
format(double, StringBuffer, FormatStatus)
- Specialization of format.
-
format(long)
- Specialization of format.
-
format(long, StringBuffer, FormatStatus)
- Specialization of format.
-
format(Object, StringBuffer, FormatStatus)
- Formats an object to produce a string.
-
getAvailableLocales()
- Get the set of Locales for which NumberFormats are installed
-
getCurrencySymbol()
- Get the currency symbol of the current locale.
-
getCurrencySymbol(Locale)
- Get the currency symbol of the desired locale.
-
getDefault()
- Gets a general-purpose number format for the current default locale
-
getDefault(Locale)
- Gets a general-purpose number format for the specified locale
-
getDefaultCurrency()
- Gets a currency format for the current default locale
-
getDefaultCurrency(Locale)
- Gets a currency format for the specified locale
-
getDefaultPercent()
- Gets a percentage format for the current default locale
-
getDefaultPercent(Locale)
- Gets a percentage format for the specified locale
-
getDisplayName(Locale)
- Get name of the object for the desired Locale, in the langauge of the
default locale.
-
getDisplayName(Locale, Locale)
- Get name of the object for the desired Locale, in the desired langauge.
-
getIntlCurrencySymbol()
- Get the international currency symbol of the current locale.
-
getIntlCurrencySymbol(Locale)
- Get the international currency symbol of the desired locale.
-
getMaximumDecimalCount()
- Allows you to get the maximum and minimum digit counts for the
decimal portion.
-
getMaximumIntegerCount()
- Allows you to get the maximum digit count for the integer portion.
-
getMinimumDecimalCount()
- Allows you to get the maximum and minimum digit counts for the
decimal portion.
-
getMinimumIntegerCount()
- Allows you to get the minimum digit count for the integer portion.
-
isDecimalUsedWithInteger()
- Allows you to get the behavior of the decimal separator with integers.
-
isIntegerOnly()
- Gets flag that indicates that it stops at a decimal point
(or equivalent; e.g.
-
isThousandsUsed()
- Allows you to get the behavior of the thousands separator.
-
parse(String)
- Convenience method.
-
parse(String, ParseStatus)
- Returns a Long if possible (e.g.
-
parseObject(String, ParseStatus)
- Parses a string to produce an object.
-
setDecimalUsedWithInteger(boolean)
- Allows you to set the behavior of the decimal separator with integers.
-
setIntegerOnly(boolean)
- Sets flag that indicates that it stops at a decimal point
(or equivalent; e.g.
-
setMaximumDecimalCount(int)
- Allows you to set the maximum and minimum digit counts for the
decimal portion.
-
setMaximumIntegerCount(int)
- Allows you to set the maximum digit count for the integer portion.
-
setMinimumDecimalCount(int)
- Allows you to set the maximum and minimum digit counts for the
decimal portion.
-
setMinimumIntegerCount(int)
- Allows you to set the minimum digit count for the integer portion.
-
setThousandsUsed(boolean)
- Allows you to set the behavior of the thousands separator.
INTEGER_FIELD
public final static byte INTEGER_FIELD
- Integer field is the alignment field.
DECIMAL_FIELD
public final static byte DECIMAL_FIELD
- Decimal field is the alignment field.
NUMBERATOR_FIELD
public final static byte NUMBERATOR_FIELD
- Numerator field is the alignment field.
DENOMINATOR_FIELD
public final static byte DENOMINATOR_FIELD
- Denominator field is the alignment field.
EXPONENT_FIELD
public final static byte EXPONENT_FIELD
- Exponent field is the alignment field.
NumberFormat
public NumberFormat()
format
public final StringBuffer format(Object number,
StringBuffer toAppendTo,
FormatStatus status)
- Formats an object to produce a string.
- Overrides:
- format in class Format
parseObject
public final Object parseObject(String source,
ParseStatus status)
- Parses a string to produce an object.
- Overrides:
- parseObject in class Format
format
public final String format(double number)
- Specialization of format.
- See Also:
- format
format
public final String format(long number)
- Specialization of format.
- See Also:
- format
format
public abstract StringBuffer format(double number,
StringBuffer toAppendTo,
FormatStatus status)
- Specialization of format.
- See Also:
- format
format
public abstract StringBuffer format(long number,
StringBuffer toAppendTo,
FormatStatus status)
- Specialization of format.
- See Also:
- format
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
parse
public Number parse(String text) throws FormatException
- Convenience method.
- See Also:
- format
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).
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).
getDefault
public final static synchronized NumberFormat getDefault()
- Gets a general-purpose number format for the current default locale
- Returns:
- general-purpose number format
getDefaultCurrency
public final static synchronized NumberFormat getDefaultCurrency()
- Gets a currency format for the current default locale
- Returns:
- currency format
getDefaultPercent
public final static synchronized NumberFormat getDefaultPercent()
- Gets a percentage format for the current default locale
- Returns:
- percentage number format
getDefault
public static synchronized NumberFormat getDefault(Locale inLocale)
- Gets a general-purpose number format for the specified locale
- Returns:
- general-purpose number format
getDefaultCurrency
public static synchronized NumberFormat getDefaultCurrency(Locale inLocale)
- Gets a currency format for the specified locale
- Returns:
- currency format
getDefaultPercent
public static synchronized NumberFormat getDefaultPercent(Locale inLocale)
- Gets a percentage format for the specified locale
- Returns:
- percentage number format
getAvailableLocales
public static synchronized Locale[] getAvailableLocales()
- Get the set of Locales for which NumberFormats are installed
- Returns:
- available locales
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
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
getCurrencySymbol
public final String getCurrencySymbol()
- Get the currency symbol of the current locale.
- Returns:
- the currency symbol
getCurrencySymbol
public final String getCurrencySymbol(Locale loc)
- Get the currency symbol of the desired locale.
- Parameters:
- loc - the desired locale
- Returns:
- the currency symbol
getIntlCurrencySymbol
public final String getIntlCurrencySymbol()
- Get the international currency symbol of the current locale.
- Returns:
- the international currency symbol
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
clone
public Object clone()
- Overrides Cloneable
- Overrides:
- clone in class Object
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
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
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
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
getMaximumIntegerCount
public int getMaximumIntegerCount()
- Allows you to get the maximum digit count for the integer portion.
Example: with different values, 123 -> 123; 00,123;
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;
getMinimumIntegerCount
public int getMinimumIntegerCount()
- Allows you to get the minimum digit count for the integer portion.
Example: with different values, 123 -> 123; 00,123;
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;
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
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
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
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