I was running some code and was getting a strange error I could not understand. So i tried to debug it and ran multiple test and found this this is the code I am running
@Test
public void test(){
LocalDate firstDay = LocalDate.parse("2020-12-01");
LocalDate lastDay = LocalDate.parse("2020-12-31");
String firstDayString = firstDay.format(DateTimeFormatter.ofPattern("YYYYMMdd"));
String lastDayString = lastDay.format(DateTimeFormatter.ofPattern("YYYYMMdd"));
System.out.println(firstDayString);
System.out.println(lastDayString);
}
And this is the output
20201201
20211231
please note the year for the last date changed to 2021 when i tried to do the format. Any one else has notice this?