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.
parse
has the following syntax.
public static LocalDate parse(CharSequence text)
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.