Java LocalDate create from TemporalAccessor by parsing String like "01/31/2018"

Description

Java LocalDate create from TemporalAccessor by parsing String like "01/31/2018"

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;

public class Main {
   public static void main(String[] args) {
      DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
      TemporalAccessor ta = formatter.parse("01/31/2018");
      LocalDate ld = LocalDate.from(ta);
      System.out.println(ld);//from ww w.j  a  v  a  2s  . co m
   }
}



PreviousNext

Related