Java DateTimeFormatter parse String like "01/31/2018"

Description

Java DateTimeFormatter parse String like "01/31/2018"

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

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



PreviousNext

Related