次の方法で共有


DateTimeFormatter.Parse Method

Definition

Overloads

Parse(ICharSequence)

Fully parses the text producing a temporal object.

Parse(String)

Fully parses the text producing a temporal object.

Parse(ICharSequence, ParsePosition)

Parses the text using this formatter, providing control over the text position.

Parse(ICharSequence, ITemporalQuery)

Fully parses the text producing an object of the specified type.

Parse(String, ParsePosition)

Parses the text using this formatter, providing control over the text position.

Parse(String, ITemporalQuery)

Fully parses the text producing an object of the specified type.

Parse(ICharSequence)

Fully parses the text producing a temporal object.

[Android.Runtime.Register("parse", "(Ljava/lang/CharSequence;)Ljava/time/temporal/TemporalAccessor;", "", ApiSince=26)]
public Java.Time.Temporal.ITemporalAccessor? Parse (Java.Lang.ICharSequence? text);
[<Android.Runtime.Register("parse", "(Ljava/lang/CharSequence;)Ljava/time/temporal/TemporalAccessor;", "", ApiSince=26)>]
member this.Parse : Java.Lang.ICharSequence -> Java.Time.Temporal.ITemporalAccessor

Parameters

text
ICharSequence

the text to parse, not null

Returns

the parsed temporal object, not null

Attributes

Remarks

Fully parses the text producing a temporal object.

This parses the entire text producing a temporal object. It is typically more useful to use #parse(CharSequence, TemporalQuery). The result of this method is TemporalAccessor which has been resolved, applying basic validation checks to help ensure a valid date-time.

If the parse completes without reading the entire length of the text, or a problem occurs during parsing or merging, then an exception is thrown.

Java documentation for java.time.format.DateTimeFormatter.parse(java.lang.CharSequence).

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)

Fully parses the text producing a temporal object.

public Java.Time.Temporal.ITemporalAccessor? Parse (string? text);
member this.Parse : string -> Java.Time.Temporal.ITemporalAccessor

Parameters

text
String

the text to parse, not null

Returns

the parsed temporal object, not null

Remarks

Fully parses the text producing a temporal object.

This parses the entire text producing a temporal object. It is typically more useful to use #parse(CharSequence, TemporalQuery). The result of this method is TemporalAccessor which has been resolved, applying basic validation checks to help ensure a valid date-time.

If the parse completes without reading the entire length of the text, or a problem occurs during parsing or merging, then an exception is thrown.

Java documentation for java.time.format.DateTimeFormatter.parse(java.lang.CharSequence).

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(ICharSequence, ParsePosition)

Parses the text using this formatter, providing control over the text position.

[Android.Runtime.Register("parse", "(Ljava/lang/CharSequence;Ljava/text/ParsePosition;)Ljava/time/temporal/TemporalAccessor;", "", ApiSince=26)]
public Java.Time.Temporal.ITemporalAccessor? Parse (Java.Lang.ICharSequence? text, Java.Text.ParsePosition? position);
[<Android.Runtime.Register("parse", "(Ljava/lang/CharSequence;Ljava/text/ParsePosition;)Ljava/time/temporal/TemporalAccessor;", "", ApiSince=26)>]
member this.Parse : Java.Lang.ICharSequence * Java.Text.ParsePosition -> Java.Time.Temporal.ITemporalAccessor

Parameters

text
ICharSequence

the text to parse, not null

position
ParsePosition

the position to parse from, updated with length parsed and the index of any error, not null

Returns

the parsed temporal object, not null

Attributes

Remarks

Parses the text using this formatter, providing control over the text position.

This parses the text without requiring the parse to start from the beginning of the string or finish at the end. The result of this method is TemporalAccessor which has been resolved, applying basic validation checks to help ensure a valid date-time.

The text will be parsed from the specified start ParsePosition. The entire length of the text does not have to be parsed, the ParsePosition will be updated with the index at the end of parsing.

The operation of this method is slightly different to similar methods using ParsePosition on java.text.Format. That class will return errors using the error index on the ParsePosition. By contrast, this method will throw a DateTimeParseException if an error occurs, with the exception containing the error index. This change in behavior is necessary due to the increased complexity of parsing and resolving dates/times in this API.

If the formatter parses the same field more than once with different values, the result will be an error.

Java documentation for java.time.format.DateTimeFormatter.parse(java.lang.CharSequence, 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(ICharSequence, ITemporalQuery)

Fully parses the text producing an object of the specified type.

[Android.Runtime.Register("parse", "(Ljava/lang/CharSequence;Ljava/time/temporal/TemporalQuery;)Ljava/lang/Object;", "", ApiSince=26)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public Java.Lang.Object? Parse (Java.Lang.ICharSequence? text, Java.Time.Temporal.ITemporalQuery? query);
[<Android.Runtime.Register("parse", "(Ljava/lang/CharSequence;Ljava/time/temporal/TemporalQuery;)Ljava/lang/Object;", "", ApiSince=26)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
member this.Parse : Java.Lang.ICharSequence * Java.Time.Temporal.ITemporalQuery -> Java.Lang.Object

Parameters

text
ICharSequence

the text to parse, not null

query
ITemporalQuery

the query defining the type to parse to, not null

Returns

the parsed date-time, not null

Attributes

Remarks

Fully parses the text producing an object of the specified type.

Most applications should use this method for parsing. It parses the entire text to produce the required date-time. The query is typically a method reference to a from(TemporalAccessor) method. For example:

LocalDateTime dt = parser.parse(str, LocalDateTime::from);

If the parse completes without reading the entire length of the text, or a problem occurs during parsing or merging, then an exception is thrown.

Java documentation for java.time.format.DateTimeFormatter.parse(java.lang.CharSequence, java.time.temporal.TemporalQuery<T>).

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)

Parses the text using this formatter, providing control over the text position.

public Java.Time.Temporal.ITemporalAccessor? Parse (string? text, Java.Text.ParsePosition? position);
member this.Parse : string * Java.Text.ParsePosition -> Java.Time.Temporal.ITemporalAccessor

Parameters

text
String

the text to parse, not null

position
ParsePosition

the position to parse from, updated with length parsed and the index of any error, not null

Returns

the parsed temporal object, not null

Remarks

Parses the text using this formatter, providing control over the text position.

This parses the text without requiring the parse to start from the beginning of the string or finish at the end. The result of this method is TemporalAccessor which has been resolved, applying basic validation checks to help ensure a valid date-time.

The text will be parsed from the specified start ParsePosition. The entire length of the text does not have to be parsed, the ParsePosition will be updated with the index at the end of parsing.

The operation of this method is slightly different to similar methods using ParsePosition on java.text.Format. That class will return errors using the error index on the ParsePosition. By contrast, this method will throw a DateTimeParseException if an error occurs, with the exception containing the error index. This change in behavior is necessary due to the increased complexity of parsing and resolving dates/times in this API.

If the formatter parses the same field more than once with different values, the result will be an error.

Java documentation for java.time.format.DateTimeFormatter.parse(java.lang.CharSequence, 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, ITemporalQuery)

Fully parses the text producing an object of the specified type.

public Java.Lang.Object? Parse (string? text, Java.Time.Temporal.ITemporalQuery? query);
member this.Parse : string * Java.Time.Temporal.ITemporalQuery -> Java.Lang.Object

Parameters

text
String

the text to parse, not null

query
ITemporalQuery

the query defining the type to parse to, not null

Returns

the parsed date-time, not null

Remarks

Fully parses the text producing an object of the specified type.

Most applications should use this method for parsing. It parses the entire text to produce the required date-time. The query is typically a method reference to a from(TemporalAccessor) method. For example:

LocalDateTime dt = parser.parse(str, LocalDateTime::from);

If the parse completes without reading the entire length of the text, or a problem occurs during parsing or merging, then an exception is thrown.

Java documentation for java.time.format.DateTimeFormatter.parse(java.lang.CharSequence, java.time.temporal.TemporalQuery<T>).

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