-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8
ADDITIONAL SYSTEM INFORMATION :
Linux / Windows / Latest JDK as well
A DESCRIPTION OF THE PROBLEM :
When using SimpleDateFormat format (dd/MMM/YYYY:HH:mm:ss Z), I am seeing YEAR returned as 2020 from 29th Dec 2019. However, "yyyy" (small case) works as expected. This behavior is noticed only from 29th December 2019 and this would again start returning year as 2020 from Jan 1st. (so only 29th, 30th and 31st of Dec 2019, we will have this problem)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Specify the format string as "dd/MMM/YYYY:HH:mm:ss Z" in SimpleDateFormat constructor.
2. Use current Date
3. Format the date using above formatter.
4. Print the date
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Current Time 1577691758596
30/Dec/2019:13:12:38 +0530
ACTUAL -
Current Time 1577691758596
30/Dec/2020:13:12:38 +0530
---------- BEGIN SOURCE ----------
SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/YYYY:HH:mm:ss Z", Locale.US);
formatter.setTimeZone(TimeZone.getDefault());
long currentTime = System.currentTimeMillis();
System.out.println("Current Time " + currentTime);
String dateString = formatter.format(new Date(currentTime));
System.out.println(dateString);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
changing YYYY to yyyy fixes the problem.
FREQUENCY : always
Linux / Windows / Latest JDK as well
A DESCRIPTION OF THE PROBLEM :
When using SimpleDateFormat format (dd/MMM/YYYY:HH:mm:ss Z), I am seeing YEAR returned as 2020 from 29th Dec 2019. However, "yyyy" (small case) works as expected. This behavior is noticed only from 29th December 2019 and this would again start returning year as 2020 from Jan 1st. (so only 29th, 30th and 31st of Dec 2019, we will have this problem)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Specify the format string as "dd/MMM/YYYY:HH:mm:ss Z" in SimpleDateFormat constructor.
2. Use current Date
3. Format the date using above formatter.
4. Print the date
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Current Time 1577691758596
30/Dec/2019:13:12:38 +0530
ACTUAL -
Current Time 1577691758596
30/Dec/2020:13:12:38 +0530
---------- BEGIN SOURCE ----------
SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/YYYY:HH:mm:ss Z", Locale.US);
formatter.setTimeZone(TimeZone.getDefault());
long currentTime = System.currentTimeMillis();
System.out.println("Current Time " + currentTime);
String dateString = formatter.format(new Date(currentTime));
System.out.println(dateString);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
changing YYYY to yyyy fixes the problem.
FREQUENCY : always
- duplicates
-
JDK-8235968 Bad date(year) formating: Output is 30-12-2020 instead of 30-12-2019
- Closed