Java 8 Time API: how to parse string of format “MM.yyyy” to LocalDate
问题 I'm a bit discouraged with parsing dates in Java 8 Time API . Previously I could easily write: String date = "04.2013"; DateFormat df = new SimpleDateFormat("MM.yyyy"); Date d = df.parse(date); But now if I use LocalDate and do it like this: String date = "04.2013"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM.yyyy"); LocalDate ld = LocalDate.parse(date, formatter); I receive an exception: java.time.format.DateTimeParseException: Text '04' could not be parsed at index 0 java