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