Java Date Time - LocalDate parse(CharSequence text) example








LocalDate parse(CharSequence text) creates an instance of LocalDate from a text string such as 2007-12-03.

The string must represent a valid date and is parsed using DateTimeFormatter.ISO_LOCAL_DATE.

Syntax

parse has the following syntax.

public static LocalDate parse(CharSequence text)

Example

The following example shows how to use parse.

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
//w w w .j  a  va 2 s  .  c  o  m
public class Main {
  public static void main(String[] args) {
    LocalDate a = LocalDate.parse("2007-12-03");
    
    System.out.println(a);
  }
}

The code above generates the following result.