Java Date Time - LocalDateTime parse(CharSequence text) example








LocalDateTime parse(CharSequence text) gets an instance of LocalDateTime from a text string such as 2014-12-03T10:15:30.

The string must represent a valid date-time and is parsed using <code>DateTimeFormatter.ISO_LOCAL_DATE_TIME</code>.

Syntax

parse has the following syntax.

public static LocalDateTime parse(CharSequence text)

Example

The following example shows how to use parse.

import java.time.LocalDateTime;

public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.parse("2014-06-30T12:01:00");
    
    System.out.println(a);
  }
}

The code above generates the following result.