Language

DecimalFormat.Parse(String, ParsePosition) Method

Definition

Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, Long.MAX_VALUE] and with no decimals); otherwise, returns another type, such as a BigDecimal, BigInteger, or Double.

[Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/lang/Number;", "GetParse_Ljava_lang_String_Ljava_text_ParsePosition_Handler", ApiSince=24)]
public override 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)>]
override this.Parse : string * Java.Text.ParsePosition -> Java.Lang.Number

Parameters

text
String

The text in which to parse a number using this formatter's parsing settings.

parsePosition
ParsePosition

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

Returns

The parsed numeric value, or null when parsing fails.

Attributes

Remarks

Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, Long.MAX_VALUE] and with no decimals); otherwise, returns another type, such as a BigDecimal, BigInteger, or Double. The return type is not guaranteed other than for the Long case. 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! For more detail on parsing, see the "Parsing" header in the class documentation of DecimalFormat.

Java documentation for android.icu.text.DecimalFormat.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