Java Date Time - ZonedDateTime parse(CharSequence text) example








ZonedDateTime parse(CharSequence text) creates an instance of ZonedDateTime from a text string such as 2014-12-03T10:15:30+01:00[Europe/Paris].

The string must represent a valid date-time and is parsed using DateTimeFormatter.ISO_ZONED_DATE_TIME.

Syntax

parse has the following syntax.

public static ZonedDateTime parse(CharSequence text)

Example

The following example shows how to use parse.

import java.time.ZonedDateTime;

public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime =ZonedDateTime.parse("2014-09-03T11:38:45.902-07:00[America/Los_Angeles]");

    System.out.println(dateTime);
  } 
}

The code above generates the following result.