Java Date Time - Instant parse(CharSequence text) example








Instant parse(CharSequence text) gets an instance of Instant from a text string such as 2007-12-03T10:15:30.00Z.

The string must represent a valid instant in UTC and is parsed using DateTimeFormatter.ISO_INSTANT.

Syntax

parse has the following syntax.

public static Instant parse(CharSequence text)

Example

The following example shows how to use parse.

import java.time.Instant;

public class Main {
  public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    System.out.println(instant);
  }
}

The code above generates the following result.