Java Data Type How to - Parse date in form of '2013-01-12'








Question

We would like to know how to parse date in form of '2013-01-12'.

Answer

import java.time.LocalDate;

public class Main {
  public static void main(String[] argv) {
    LocalDate d = LocalDate.parse("2013-01-12");
    System.out.println(d);
  }
}

The code above generates the following result.