ZonedDateTime parse(CharSequence text, DateTimeFormatter formatter) example

Description

ZonedDateTime parse(CharSequence text, DateTimeFormatter formatter) creates an instance of ZonedDateTime from a text string using a specific formatter.

Syntax

parse has the following syntax.


public static ZonedDateTime parse(CharSequence text,   DateTimeFormatter formatter)

Example

The following example shows how to use parse.


import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
//from  w w w  .j  av a  2  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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset