Language

NumberFormat.Parse Method

Definition

Overloads

Name Description
Parse(String)

Parses text from the beginning of the given string to produce a number.

Parse(String, ParsePosition)

Returns a parsed number. The returned numeric type depends on the implementation and its settings.

Parse(String)

Parses text from the beginning of the given string to produce a number.

[Android.Runtime.Register("parse", "(Ljava/lang/String;)Ljava/lang/Number;", "GetParse_Ljava_lang_String_Handler", ApiSince=24)]
public virtual Java.Lang.Number? Parse(string? text);
[<Android.Runtime.Register("parse", "(Ljava/lang/String;)Ljava/lang/Number;", "GetParse_Ljava_lang_String_Handler", ApiSince=24)>]
abstract member Parse : string -> Java.Lang.Number
override this.Parse : string -> Java.Lang.Number

Parameters

text
String

A String whose beginning should be parsed.

Returns

A Number parsed from the string.

Attributes

Remarks

Parses text from the beginning of the given string to produce a number. The method might not use the entire text of the given string.

Java documentation for android.icu.text.NumberFormat.parse(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Parse(String, ParsePosition)

Returns a parsed number. The returned numeric type depends on the implementation and its settings.

[Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/lang/Number;", "GetParse_Ljava_lang_String_Ljava_text_ParsePosition_Handler", ApiSince=24)]
public abstract Java.Lang.Number? Parse(string? text, Java.Text.ParsePosition? parsePosition);
[<Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/lang/Number;", "GetParse_Ljava_lang_String_Ljava_text_ParsePosition_Handler", ApiSince=24)>]
abstract member Parse : string * Java.Text.ParsePosition -> Java.Lang.Number

Parameters

text
String

The text in which to parse a number.

parsePosition
ParsePosition

Its index selects where parsing begins and advances on success; its error index can report a parsing failure.

Returns

The parsed number. Some implementations return null when parsing fails; others can return a number without consuming text.

Attributes

Remarks

The returned numeric type depends on the implementation and its settings. For example, ParseBigDecimal makes DecimalFormat prefer a BigDecimal result when possible.

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).

If no object can be parsed, the index is unchanged. Compare Index before and after the call to check whether text was consumed. An implementation can throw an exception for invalid arguments.

For more detail on parsing, see the "Parsing" header in the class documentation of DecimalFormat.

Java documentation for android.icu.text.NumberFormat.parse(java.lang.String, java.text.ParsePosition).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to