-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Local date is 31/12/2021 but when we format date using DateTimeFormatter we get date in which year value is changed to next year
for eg. current date is 31/12/2021 but after formatting we get 31/12/2022
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See the source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
31/12/2021
ACTUAL -
31/12/2022
---------- BEGIN SOURCE ----------
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class Main {
public static void main(String[] args) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MMM dd, YYYY");
LocalDate localdate = LocalDate.of(2021, 12, 31);
System.out.println(localdate);
System.out.println(dtf.format(localdate));
}
}
---------- END SOURCE ----------
Local date is 31/12/2021 but when we format date using DateTimeFormatter we get date in which year value is changed to next year
for eg. current date is 31/12/2021 but after formatting we get 31/12/2022
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See the source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
31/12/2021
ACTUAL -
31/12/2022
---------- BEGIN SOURCE ----------
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class Main {
public static void main(String[] args) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MMM dd, YYYY");
LocalDate localdate = LocalDate.of(2021, 12, 31);
System.out.println(localdate);
System.out.println(dtf.format(localdate));
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8323167 java.time.format.DateTimeFormatter adds an extra year while formatting
-
- Closed
-