java.io.Serializable, java.lang.Cloneablepublic class OptionalNumberFormat
extends java.text.Format
NumberFormat capable of handling nulls and empty strings.| Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals(java.lang.Object other) |
|
java.lang.String |
format(double number) |
Formats a
double number. |
java.lang.String |
format(long number) |
Formats a
long number. |
java.lang.StringBuffer |
format(java.lang.Object source,
java.lang.StringBuffer buffer,
java.text.FieldPosition position) |
|
static java.util.Locale[] |
getAvailableLocales() |
Returns all locales supported by the
get*Instance() methods. |
java.util.Currency |
getCurrency() |
Returns the currency used by this format when formatting currency values.
|
static OptionalNumberFormat |
getCurrencyInstance() |
Returns a currency format for the current default locale.
|
static OptionalNumberFormat |
getCurrencyInstance(java.util.Locale locale) |
Returns a currency format for the given locale.
|
static OptionalNumberFormat |
getInstance() |
Returns a general-purpose number format for the current default locale.
|
static OptionalNumberFormat |
getInstance(java.util.Locale locale) |
Returns a general-purpose number format for the given locale.
|
static OptionalNumberFormat |
getIntegerInstance() |
Returns an integer number format for the current default locale.
|
static OptionalNumberFormat |
getIntegerInstance(java.util.Locale locale) |
Returns an integer number format for the given locale.
|
int |
getMaximumFractionDigits() |
Returns the maximum number of digits allowed in the fraction part of a number.
|
int |
getMaximumIntegerDigits() |
Returns the maximum number of digits allowed in the integer part of a number.
|
int |
getMinimumFractionDigits() |
Returns the minimum number of digits allowed in the fraction part of a number.
|
int |
getMinimumIntegerDigits() |
Returns the minimum number of digits allowed in the integer part of a number.
|
static OptionalNumberFormat |
getNumberInstance() |
Returns a general-purpose number format for the current default locale.
|
static OptionalNumberFormat |
getNumberInstance(java.util.Locale locale) |
Returns a general-purpose number format for the given locale.
|
static OptionalNumberFormat |
getPercentInstance() |
Returns a percentage format for the current default locale.
|
static OptionalNumberFormat |
getPercentInstance(java.util.Locale locale) |
Returns a percentage format for the given locale.
|
java.math.RoundingMode |
getRoundingMode() |
Returns the rounding mode used in this format.
|
int |
hashCode() |
|
boolean |
isGroupingUsed() |
Checks whether grouping is used in this format.
|
boolean |
isParseIntegerOnly() |
Checks whether numbers shall be parsed as integers only.
|
java.lang.Object |
parseObject(java.lang.String source) |
|
java.lang.Object |
parseObject(java.lang.String source,
java.text.ParsePosition position) |
|
void |
setCurrency(java.util.Currency currency) |
Sets the currency used by this format when formatting currency values.
|
void |
setGroupingUsed(boolean value) |
Sets whether grouping is used in this format.
|
void |
setMaximumFractionDigits(int value) |
Sets the maximum number of digits allowed in the fraction part of a number.
|
void |
setMaximumIntegerDigits(int value) |
Sets the maximum number of digits allowed in the integer part of a number.
|
void |
setMinimumFractionDigits(int value) |
Sets the minimum number of digits allowed in the fraction part of a number.
|
void |
setMinimumIntegerDigits(int value) |
Sets the minimum number of digits allowed in the integer part of a number.
|
void |
setParseIntegerOnly(boolean value) |
Sets whether numbers shall be parsed as integers only.
|
void |
setRoundingMode(java.math.RoundingMode roundingMode) |
Sets the rounding mode used in this format.
|
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic java.lang.String format(double number)
double number.public java.lang.String format(long number)
long number.public java.lang.StringBuffer format(java.lang.Object source,
java.lang.StringBuffer buffer,
java.text.FieldPosition position)
format in class java.text.Formatpublic static java.util.Locale[] getAvailableLocales()
get*Instance() methods.public java.util.Currency getCurrency()
public static OptionalNumberFormat getCurrencyInstance()
public static OptionalNumberFormat getCurrencyInstance(java.util.Locale locale)
java.lang.IllegalArgumentException - if locale is nullpublic static OptionalNumberFormat getInstance()
public static OptionalNumberFormat getInstance(java.util.Locale locale)
java.lang.IllegalArgumentException - if locale is nullpublic static OptionalNumberFormat getIntegerInstance()
public static OptionalNumberFormat getIntegerInstance(java.util.Locale locale)
java.lang.IllegalArgumentException - if locale is nullpublic int getMaximumFractionDigits()
public int getMaximumIntegerDigits()
public int getMinimumFractionDigits()
public int getMinimumIntegerDigits()
public static OptionalNumberFormat getNumberInstance()
public static OptionalNumberFormat getNumberInstance(java.util.Locale locale)
java.lang.IllegalArgumentException - if locale is nullpublic static OptionalNumberFormat getPercentInstance()
public static OptionalNumberFormat getPercentInstance(java.util.Locale locale)
java.lang.IllegalArgumentException - if locale is nullpublic java.math.RoundingMode getRoundingMode()
public boolean isGroupingUsed()
public boolean isParseIntegerOnly()
public java.lang.Object parseObject(java.lang.String source)
throws java.text.ParseException
parseObject in class java.text.Formatjava.text.ParseExceptionpublic java.lang.Object parseObject(java.lang.String source,
java.text.ParsePosition position)
parseObject in class java.text.Formatpublic int hashCode()
hashCode in class java.lang.Objectpublic void setCurrency(java.util.Currency currency)
public void setGroupingUsed(boolean value)
public void setMaximumFractionDigits(int value)
public void setMaximumIntegerDigits(int value)
public void setMinimumFractionDigits(int value)
public void setMinimumIntegerDigits(int value)
public void setParseIntegerOnly(boolean value)
public void setRoundingMode(java.math.RoundingMode roundingMode)