OffsetDateTime parse(CharSequence text, DateTimeFormatter formatter)
creates an instance of OffsetDateTime from a text string using a specific formatter.
parse
has the following syntax.
public static OffsetDateTime parse(CharSequence text, DateTimeFormatter formatter)
The following example shows how to use parse
.
import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; //from w w w . j ava2 s . c o m public class Main { public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.parse("2014-09-02T15:22:14.59-07:00",DateTimeFormatter.ISO_DATE_TIME); System.out.println(o); } }
The code above generates the following result.