-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8, 9
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
I want my Java program to add weeks in year to a given week, which is in "yyyyww" format.
For example I have "201701" which indicates 1st week of the year 2017. I want to add 2 weeks to this value. So I use "add" method of java.util.Calendar class (more details mentioned in source code). I get 201703. Perfect till now.
If I add 1 week to 201752 then I get 201801. Perfect.
But when I add 1 week to 201852 then I get 201801. Oops!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
201901
ACTUAL -
201801
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
final String startWeek = "201852";
SimpleDateFormat sdf = sdf = new SimpleDateFormat("yyyyww");
Calendar calStart = Calendar.getInstance();
calStart.setTime(sdf.parse(startWeek));
calStart.add(Calendar.WEEK_OF_YEAR, 1);
System.out.println(sdf.format(calStart.getTime()));
---------- END SOURCE ----------
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
I want my Java program to add weeks in year to a given week, which is in "yyyyww" format.
For example I have "201701" which indicates 1st week of the year 2017. I want to add 2 weeks to this value. So I use "add" method of java.util.Calendar class (more details mentioned in source code). I get 201703. Perfect till now.
If I add 1 week to 201752 then I get 201801. Perfect.
But when I add 1 week to 201852 then I get 201801. Oops!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
201901
ACTUAL -
201801
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
final String startWeek = "201852";
SimpleDateFormat sdf = sdf = new SimpleDateFormat("yyyyww");
Calendar calStart = Calendar.getInstance();
calStart.setTime(sdf.parse(startWeek));
calStart.add(Calendar.WEEK_OF_YEAR, 1);
System.out.println(sdf.format(calStart.getTime()));
---------- END SOURCE ----------
- relates to
-
JDK-8225641 Calendar.roll(int field) does not work correctly for WEEK_OF_YEAR
-
- Closed
-