convert string to localdate in java using format code example
Example 1: java 8 string to localdate
package com.mkyong.date;
import java.time.LocalDate;
public class JavaDateExample1 {
public static void main(String[] args) {
String date = "2016-08-16";
LocalDate localDate = LocalDate.parse(date);
System.out.println(localDate);
}
}
Copy
Example 2: string to localdate in java
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/MM/yyyy");
String date = "16/08/2016";
LocalDate localDate = LocalDate.parse(date, formatter);