Partager via


DateFormat.Parse Method

Definition

Overloads

Parse(String, ParsePosition)

Parse a date/time string according to the given parse position.

Parse(String)

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

Parse(String, ParsePosition)

Parse a date/time string according to the given parse position.

[Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/util/Date;", "GetParse_Ljava_lang_String_Ljava_text_ParsePosition_Handler")]
public abstract Java.Util.Date? Parse (string source, Java.Text.ParsePosition pos);
[<Android.Runtime.Register("parse", "(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/util/Date;", "GetParse_Ljava_lang_String_Ljava_text_ParsePosition_Handler")>]
abstract member Parse : string * Java.Text.ParsePosition -> Java.Util.Date

Parameters

source
String

The date/time string to be parsed

pos
ParsePosition

On input, the position at which to start parsing; on output, the position at which parsing terminated, or the start position if the parse failed.

Returns

A Date, or null if the input could not be parsed

Attributes

Remarks

Parse a date/time string according to the given parse position. For example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date that is equivalent to Date(837039900000L).

By default, parsing is lenient: If the input is not in the form used by this object's format method but can still be parsed as a date, then the parse succeeds. Clients may insist on strict adherence to the format by calling #setLenient(boolean) setLenient(false).

This parsing operation uses the #calendar to produce a Date. As a result, the calendar's date-time fields and the TimeZone value may have been overwritten, depending on subclass implementations. Any TimeZone value that has previously been set by a call to #setTimeZone(java.util.TimeZone) setTimeZone may need to be restored for further operations.

Java documentation for java.text.DateFormat.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

Parse(String)

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

[Android.Runtime.Register("parse", "(Ljava/lang/String;)Ljava/util/Date;", "GetParse_Ljava_lang_String_Handler")]
public virtual Java.Util.Date? Parse (string source);
[<Android.Runtime.Register("parse", "(Ljava/lang/String;)Ljava/util/Date;", "GetParse_Ljava_lang_String_Handler")>]
abstract member Parse : string -> Java.Util.Date
override this.Parse : string -> Java.Util.Date

Parameters

source
String

A String whose beginning should be parsed.

Returns

A Date parsed from the string.

Attributes

Exceptions

if an error occurs during parsing.

Remarks

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

See the #parse(String, ParsePosition) method for more information on date parsing.

Java documentation for java.text.DateFormat.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