java.text
Class NumberFormat

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.text.Format sample code for java.text.Format definition code for java.text.Format 
      extended by java.text.NumberFormat
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable
Direct Known Subclasses:
ChoiceFormat sample code for java.text.ChoiceFormat definition code for java.text.ChoiceFormat , DecimalFormat sample code for java.text.DecimalFormat definition code for java.text.DecimalFormat

public abstract class NumberFormat
extends Format sample code for java.text.Format definition code for java.text.Format

NumberFormat is the abstract base class for all number formats. This class provides the interface for formatting and parsing numbers. NumberFormat also provides methods for determining which locales have number formats, and what their names are.

NumberFormat helps you to format and parse numbers for any locale. Your code can be completely independent of the locale conventions for decimal points, thousands-separators, or even the particular decimal digits used, or whether the number format is even decimal.

To format a number for the current Locale, use one of the factory class methods:

  myString = NumberFormat.getInstance().format(myNumber);
 
If you are formatting multiple numbers, it is more efficient to get the format and use it multiple times so that the system doesn't have to fetch the information about the local language and country conventions multiple times.
 NumberFormat nf = NumberFormat.getInstance();
 for (int i = 0; i < a.length; ++i) {
     output.println(nf.format(myNumber[i]) + "; ");
 }
 
To format a number for a different Locale, specify it in the call to getInstance.
 NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH);
 
You can also use a NumberFormat to parse numbers:
 myNumber = nf.parse(myString);
 
Use getInstance or getNumberInstance to get the normal number format. Use getIntegerInstance to get an integer number format. Use getCurrencyInstance to get the currency number format. And use getPercentInstance to get a format for displaying percentages. With this format, a fraction like 0.53 is displayed as 53%.

You can also control the display of numbers with such methods as setMinimumFractionDigits. If you want even more control over the format or parsing, or want to give your users more control, you can try casting the NumberFormat you get from the factory methods to a DecimalFormat. This will work for the vast majority of locales; just remember to put it in a try block in case you encounter an unusual one.

NumberFormat and DecimalFormat are designed such that some controls work for formatting and others work for parsing. The following is the detailed description for each these control methods,

setParseIntegerOnly : only affects parsing, e.g. if true, "3456.78" -> 3456 (and leaves the parse position just after index 6) if false, "3456.78" -> 3456.78 (and leaves the parse position just after index 8) This is independent of formatting. If you want to not show a decimal point where there might be no digits after the decimal point, use setDecimalSeparatorAlwaysShown.

setDecimalSeparatorAlwaysShown : only affects formatting, and only where there might be no digits after the decimal point, such as with a pattern like "#,##0.##", e.g., if true, 3456.00 -> "3,456." if false, 3456.00 -> "3456" This is independent of parsing. If you want parsing to stop at the decimal point, use setParseIntegerOnly.

You can also use forms of the parse and format methods with ParsePosition and FieldPosition to allow you to:

For example, you can align numbers in two ways:
  1. If you are using a monospaced font with spacing for alignment, you can pass the FieldPosition in your format call, with field = INTEGER_FIELD. On output, getEndIndex will be set to the offset between the last character of the integer and the decimal. Add (desiredSpaceCount - getEndIndex) spaces at the front of the string.
  2. If you are using proportional fonts, instead of padding with spaces, measure the width of the string in pixels from the start to getEndIndex. Then move the pen by (desiredPixelWidth - widthToAlignmentPoint) before drawing the text. It also works where there is no decimal, but possibly additional characters at the end, e.g., with parentheses in negative numbers: "(12)" for -12.

Synchronization

Number formats are generally not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.

See Also:
DecimalFormat sample code for java.text.DecimalFormat definition code for java.text.DecimalFormat , ChoiceFormat sample code for java.text.ChoiceFormat definition code for java.text.ChoiceFormat , Serialized Form

Nested Class Summary
static class NumberFormat.Field sample code for java.text.NumberFormat.Field definition code for java.text.NumberFormat.Field
          Defines constants that are used as attribute keys in the AttributedCharacterIterator returned from NumberFormat.formatToCharacterIterator and as field identifiers in FieldPosition.
 
Field Summary
static int FRACTION_FIELD sample code for java.text.NumberFormat.FRACTION_FIELD definition code for java.text.NumberFormat.FRACTION_FIELD
          Field constant used to construct a FieldPosition object.
static int INTEGER_FIELD sample code for java.text.NumberFormat.INTEGER_FIELD definition code for java.text.NumberFormat.INTEGER_FIELD
          Field constant used to construct a FieldPosition object.
 
Constructor Summary
NumberFormat sample code for java.text.NumberFormat.NumberFormat() definition code for java.text.NumberFormat.NumberFormat() ()
           
 
Method Summary
 Object sample code for java.lang.Object definition code for java.lang.Object clone sample code for java.text.NumberFormat.clone() definition code for java.text.NumberFormat.clone() ()
          Overrides Cloneable
 boolean equals sample code for java.text.NumberFormat.equals(java.lang.Object) definition code for java.text.NumberFormat.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Overrides equals
 String sample code for java.lang.String definition code for java.lang.String format sample code for java.text.NumberFormat.format(double) definition code for java.text.NumberFormat.format(double) (double number)
          Specialization of format.
abstract  StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer format sample code for java.text.NumberFormat.format(double, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.NumberFormat.format(double, java.lang.StringBuffer, java.text.FieldPosition) (double number, StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  toAppendTo, FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition  pos)
          Specialization of format.
 String sample code for java.lang.String definition code for java.lang.String format sample code for java.text.NumberFormat.format(long) definition code for java.text.NumberFormat.format(long) (long number)
          Specialization of format.
abstract  StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer format sample code for java.text.NumberFormat.format(long, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.NumberFormat.format(long, java.lang.StringBuffer, java.text.FieldPosition) (long number, StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  toAppendTo, FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition  pos)
          Specialization of format.
 StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer format sample code for java.text.NumberFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.NumberFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) (Object sample code for java.lang.Object definition code for java.lang.Object  number, StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  toAppendTo, FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition  pos)
          Formats a number and appends the resulting text to the given string buffer.
static Locale sample code for java.util.Locale definition code for java.util.Locale [] getAvailableLocales sample code for java.text.NumberFormat.getAvailableLocales() definition code for java.text.NumberFormat.getAvailableLocales() ()
          Returns an array of all locales for which the get*Instance methods of this class can return localized instances.
 Currency sample code for java.util.Currency definition code for java.util.Currency getCurrency sample code for java.text.NumberFormat.getCurrency() definition code for java.text.NumberFormat.getCurrency() ()
          Gets the currency used by this number format when formatting currency values.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getCurrencyInstance sample code for java.text.NumberFormat.getCurrencyInstance() definition code for java.text.NumberFormat.getCurrencyInstance() ()
          Returns a currency format for the current default locale.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getCurrencyInstance sample code for java.text.NumberFormat.getCurrencyInstance(java.util.Locale) definition code for java.text.NumberFormat.getCurrencyInstance(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns a currency format for the specified locale.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getInstance sample code for java.text.NumberFormat.getInstance() definition code for java.text.NumberFormat.getInstance() ()
          Returns a general-purpose number format for the current default locale.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getInstance sample code for java.text.NumberFormat.getInstance(java.util.Locale) definition code for java.text.NumberFormat.getInstance(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns a general-purpose number format for the specified locale.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getIntegerInstance sample code for java.text.NumberFormat.getIntegerInstance() definition code for java.text.NumberFormat.getIntegerInstance() ()
          Returns an integer number format for the current default locale.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getIntegerInstance sample code for java.text.NumberFormat.getIntegerInstance(java.util.Locale) definition code for java.text.NumberFormat.getIntegerInstance(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns an integer number format for the specified locale.
 int getMaximumFractionDigits sample code for java.text.NumberFormat.getMaximumFractionDigits() definition code for java.text.NumberFormat.getMaximumFractionDigits() ()
          Returns the maximum number of digits allowed in the fraction portion of a number.
 int getMaximumIntegerDigits sample code for java.text.NumberFormat.getMaximumIntegerDigits() definition code for java.text.NumberFormat.getMaximumIntegerDigits() ()
          Returns the maximum number of digits allowed in the integer portion of a number.
 int getMinimumFractionDigits sample code for java.text.NumberFormat.getMinimumFractionDigits() definition code for java.text.NumberFormat.getMinimumFractionDigits() ()
          Returns the minimum number of digits allowed in the fraction portion of a number.
 int getMinimumIntegerDigits sample code for java.text.NumberFormat.getMinimumIntegerDigits() definition code for java.text.NumberFormat.getMinimumIntegerDigits() ()
          Returns the minimum number of digits allowed in the integer portion of a number.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getNumberInstance sample code for java.text.NumberFormat.getNumberInstance() definition code for java.text.NumberFormat.getNumberInstance() ()
          Returns a general-purpose number format for the current default locale.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getNumberInstance sample code for java.text.NumberFormat.getNumberInstance(java.util.Locale) definition code for java.text.NumberFormat.getNumberInstance(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns a general-purpose number format for the specified locale.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getPercentInstance sample code for java.text.NumberFormat.getPercentInstance() definition code for java.text.NumberFormat.getPercentInstance() ()
          Returns a percentage format for the current default locale.
static NumberFormat sample code for java.text.NumberFormat definition code for java.text.NumberFormat getPercentInstance sample code for java.text.NumberFormat.getPercentInstance(java.util.Locale) definition code for java.text.NumberFormat.getPercentInstance(java.util.Locale) (Locale sample code for java.util.Locale definition code for java.util.Locale  inLocale)
          Returns a percentage format for the specified locale.
 int hashCode sample code for java.text.NumberFormat.hashCode() definition code for java.text.NumberFormat.hashCode() ()
          Overrides hashCode
 boolean isGroupingUsed sample code for java.text.NumberFormat.isGroupingUsed() definition code for java.text.NumberFormat.isGroupingUsed() ()
          Returns true if grouping is used in this format.
 boolean isParseIntegerOnly sample code for java.text.NumberFormat.isParseIntegerOnly() definition code for java.text.NumberFormat.isParseIntegerOnly() ()
          Returns true if this format will parse numbers as integers only.
 Number sample code for java.lang.Number definition code for java.lang.Number parse sample code for java.text.NumberFormat.parse(java.lang.String) definition code for java.text.NumberFormat.parse(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  source)
          Parses text from the beginning of the given string to produce a number.
abstract  Number sample code for java.lang.Number definition code for java.lang.Number parse sample code for java.text.NumberFormat.parse(java.lang.String, java.text.ParsePosition) definition code for java.text.NumberFormat.parse(java.lang.String, java.text.ParsePosition) (String sample code for java.lang.String definition code for java.lang.String  source, ParsePosition sample code for java.text.ParsePosition definition code for java.text.ParsePosition  parsePosition)
          Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, Long.MAX_VALUE] and with no decimals), otherwise a Double.
 Object sample code for java.lang.Object definition code for java.lang.Object parseObject sample code for java.text.NumberFormat.parseObject(java.lang.String, java.text.ParsePosition) definition code for java.text.NumberFormat.parseObject(java.lang.String, java.text.ParsePosition) (String sample code for java.lang.String definition code for java.lang.String  source, ParsePosition sample code for java.text.ParsePosition definition code for java.text.ParsePosition  pos)
          Parses text from a string to produce a Number.
 void setCurrency sample code for java.text.NumberFormat.setCurrency(java.util.Currency) definition code for java.text.NumberFormat.setCurrency(java.util.Currency) (Currency sample code for java.util.Currency definition code for java.util.Currency  currency)
          Sets the currency used by this number format when formatting currency values.
 void setGroupingUsed sample code for java.text.NumberFormat.setGroupingUsed(boolean) definition code for java.text.NumberFormat.setGroupingUsed(boolean) (boolean newValue)
          Set whether or not grouping will be used in this format.
 void setMaximumFractionDigits sample code for java.text.NumberFormat.setMaximumFractionDigits(int) definition code for java.text.NumberFormat.setMaximumFractionDigits(int) (int newValue)
          Sets the maximum number of digits allowed in the fraction portion of a number.
 void setMaximumIntegerDigits sample code for java.text.NumberFormat.setMaximumIntegerDigits(int) definition code for java.text.NumberFormat.setMaximumIntegerDigits(int) (int newValue)
          Sets the maximum number of digits allowed in the integer portion of a number.
 void setMinimumFractionDigits sample code for java.text.NumberFormat.setMinimumFractionDigits(int) definition code for java.text.NumberFormat.setMinimumFractionDigits(int) (int newValue)
          Sets the minimum number of digits allowed in the fraction portion of a number.
 void setMinimumIntegerDigits sample code for java.text.NumberFormat.setMinimumIntegerDigits(int) definition code for java.text.NumberFormat.setMinimumIntegerDigits(int) (int newValue)
          Sets the minimum number of digits allowed in the integer portion of a number.
 void setParseIntegerOnly sample code for java.text.NumberFormat.setParseIntegerOnly(boolean) definition code for java.text.NumberFormat.setParseIntegerOnly(boolean) (boolean value)
          Sets whether or not numbers should be parsed as integers only.
 
Methods inherited from class java.text.Format sample code for java.text.Format definition code for java.text.Format
format sample code for java.text.Format.format(java.lang.Object) definition code for java.text.Format.format(java.lang.Object) , formatToCharacterIterator sample code for java.text.Format.formatToCharacterIterator(java.lang.Object) definition code for java.text.Format.formatToCharacterIterator(java.lang.Object) , parseObject sample code for java.text.Format.parseObject(java.lang.String) definition code for java.text.Format.parseObject(java.lang.String)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

INTEGER_FIELD sample code for java.text.NumberFormat.INTEGER_FIELD

public static final int INTEGER_FIELD
Field constant used to construct a FieldPosition object. Signifies that the position of the integer part of a formatted number should be returned.

See Also:
FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition , Constant Field Values

FRACTION_FIELD sample code for java.text.NumberFormat.FRACTION_FIELD

public static final int FRACTION_FIELD
Field constant used to construct a FieldPosition object. Signifies that the position of the fraction part of a formatted number should be returned.

See Also:
FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition , Constant Field Values
Constructor Detail

NumberFormat sample code for java.text.NumberFormat() definition code for java.text.NumberFormat()

public NumberFormat()
Method Detail

format sample code for java.text.NumberFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.NumberFormat.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)

public StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  format(Object sample code for java.lang.Object definition code for java.lang.Object  number,
                           StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  toAppendTo,
                           FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition  pos)
Formats a number and appends the resulting text to the given string buffer. The number can be of any subclass of Number sample code for java.lang.Number definition code for java.lang.Number .

This implementation extracts the number's value using Number.longValue() sample code for java.lang.Number.longValue() definition code for java.lang.Number.longValue() for all integral type values that can be converted to long without loss of information, including BigInteger values with a bit length sample code for java.math.BigInteger.bitLength() definition code for java.math.BigInteger.bitLength() of less than 64, and Number.doubleValue() sample code for java.lang.Number.doubleValue() definition code for java.lang.Number.doubleValue() for all other types. It then calls format(long,java.lang.StringBuffer,java.text.FieldPosition) sample code for java.text.NumberFormat.format(long, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.NumberFormat.format(long, java.lang.StringBuffer, java.text.FieldPosition) or format(double,java.lang.StringBuffer,java.text.FieldPosition) sample code for java.text.NumberFormat.format(double, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.NumberFormat.format(double, java.lang.StringBuffer, java.text.FieldPosition) . This may result in loss of magnitude information and precision for BigInteger and BigDecimal values.

Specified by:
format sample code for java.text.Format.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.Format.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition) in class Format sample code for java.text.Format definition code for java.text.Format
Parameters:
number - the number to format
toAppendTo - the StringBuffer to which the formatted text is to be appended
pos - On input: an alignment field, if desired. On output: the offsets of the alignment field.
Returns:
the value passed in as toAppendTo
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if number is null or not an instance of Number.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if toAppendTo or pos is null
See Also:
FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition

parseObject sample code for java.text.NumberFormat.parseObject(java.lang.String, java.text.ParsePosition) definition code for java.text.NumberFormat.parseObject(java.lang.String, java.text.ParsePosition)

public final Object sample code for java.lang.Object definition code for java.lang.Object  parseObject(String sample code for java.lang.String definition code for java.lang.String  source,
                                ParsePosition sample code for java.text.ParsePosition definition code for java.text.ParsePosition  pos)
Parses text from a string to produce a Number.

The method attempts to parse text starting at the index given by pos. If parsing succeeds, then the index of pos is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed number is returned. The updated pos can be used to indicate the starting point for the next call to this method. If an error occurs, then the index of pos is not changed, the error index of pos is set to the index of the character where the error occurred, and null is returned.

See the parse(String, ParsePosition) sample code for java.text.NumberFormat.parse(java.lang.String, java.text.ParsePosition) definition code for java.text.NumberFormat.parse(java.lang.String, java.text.ParsePosition) method for more information on number parsing.

Specified by:
parseObject sample code for java.text.Format.parseObject(java.lang.String, java.text.ParsePosition) definition code for java.text.Format.parseObject(java.lang.String, java.text.ParsePosition) in class Format sample code for java.text.Format definition code for java.text.Format
Parameters:
source - A String, part of which should be parsed.
pos - A ParsePosition object with index and error index information as described above.
Returns:
A Number parsed from the string. In case of error, returns null.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if pos is null.

format sample code for java.text.NumberFormat.format(double) definition code for java.text.NumberFormat.format(double)

public final String sample code for java.lang.String definition code for java.lang.String  format(double number)
Specialization of format.

See Also:
Format.format(java.lang.Object) sample code for java.text.Format.format(java.lang.Object) definition code for java.text.Format.format(java.lang.Object)

format sample code for java.text.NumberFormat.format(long) definition code for java.text.NumberFormat.format(long)

public final String sample code for java.lang.String definition code for java.lang.String  format(long number)
Specialization of format.

See Also:
Format.format(java.lang.Object) sample code for java.text.Format.format(java.lang.Object) definition code for java.text.Format.format(java.lang.Object)

format sample code for java.text.NumberFormat.format(double, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.NumberFormat.format(double, java.lang.StringBuffer, java.text.FieldPosition)

public abstract StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  format(double number,
                                    StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  toAppendTo,
                                    FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition  pos)
Specialization of format.

See Also:
Format.format(java.lang.Object) sample code for java.text.Format.format(java.lang.Object) definition code for java.text.Format.format(java.lang.Object)

format sample code for java.text.NumberFormat.format(long, java.lang.StringBuffer, java.text.FieldPosition) definition code for java.text.NumberFormat.format(long, java.lang.StringBuffer, java.text.FieldPosition)

public abstract StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  format(long number,
                                    StringBuffer sample code for java.lang.StringBuffer definition code for java.lang.StringBuffer  toAppendTo,
                                    FieldPosition sample code for java.text.FieldPosition definition code for java.text.FieldPosition  pos)
Specialization of format.

See Also:
Format.format(java.lang.Object) sample code for java.text.Format.format(java.lang.Object) definition code for java.text.Format.format(java.lang.Object)

parse sample code for java.text.NumberFormat.parse(java.lang.String, java.text.ParsePosition) definition code for java.text.NumberFormat.parse(java.lang.String, java.text.ParsePosition)

public abstract Number sample code for java.lang.Number definition code for java.lang.Number  parse(String sample code for java.lang.String definition code for java.lang.String  source,
                             ParsePosition sample code for java.text.ParsePosition definition code for java.text.ParsePosition  parsePosition)
Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, Long.MAX_VALUE] 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, index is unchanged!

See Also:
isParseIntegerOnly() sample code for java.text.NumberFormat.isParseIntegerOnly() definition code for java.text.NumberFormat.isParseIntegerOnly() , Format.parseObject(java.lang.String, java.text.ParsePosition) sample code for java.text.Format.parseObject(java.lang.String, java.text.ParsePosition) definition code for java.text.Format.parseObject(java.lang.String, java.text.ParsePosition)

parse sample code for java.text.NumberFormat.parse(java.lang.String) definition code for java.text.NumberFormat.parse(java.lang.String)

public Number sample code for java.lang.Number definition code for java.lang.Number  parse(String sample code for java.lang.String definition code for java.lang.String  source)
             throws ParseException sample code for java.text.ParseException definition code for java.text.ParseException 
Parse