Java LocalDate parse from String like "01/31/2018"

Description

Java LocalDate parse from String like "01/31/2018"

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

public class Main {
   public static void main(String[] args) {
      // Parse a LocalDate in MM/dd/yyyy format
      DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
      LocalDate ld2 = LocalDate.parse("01/31/2018", formatter);
      System.out.println("ld2: " + ld2);
   }//from ww w .ja  v a  2  s.  co  m
}



PreviousNext

Related