OffsetDateTime parse(CharSequence text) example
Description
OffsetDateTime parse(CharSequence text)
creates
an instance of OffsetDateTime from a text string
such as 2014-12-03T10:15:30+01:00.
The string must represent a valid date-time and is parsed using
. DateTimeFormatter.ISO_OFFSET_DATE_TIME
Syntax
parse
has the following syntax.
public static OffsetDateTime parse(CharSequence text)
Example
The following example shows how to use parse
.
import java.time.OffsetDateTime;
//from w w w . j a v a 2s. c o m
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.parse("2014-09-02T15:22:14.59-07:00");
System.out.println(o);
}
}
The code above generates the following result.