DateTimeFormatter giving wrong format for edge cases [duplicate]
问题 This question already has answers here : Java LocalDate Formatting of 2000-1-2 error [duplicate] (2 answers) Closed 2 years ago . DateTimeFormatter is not giving correct format for Dec 30 and 31 2018 as per following snippet. final String DATE_FORMAT = "YYYYMM"; DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(DATE_FORMAT); LocalDateTime startDate = LocalDateTime.of(2018,12,29,5,0,0); System.out.println(startDate.format(dateFormat)); //prints 201812 LocalDateTime startDate =