-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
5.0
-
x86
-
windows_2000
FULL PRODUCT VERSION :
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000
Service Pack 4
A DESCRIPTION OF THE PROBLEM :
When trying to display dates, there is a problem if we don't do a get before a set of a weekday of Calendar instance. It returns the first week of the month instead of the one selected by the day.
By executing this code in debug mode, everything seems to work well.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the code in test case with and without the comment
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2005/5/15
2005/5/16
2005/5/17
2005/5/18
2005/5/19
2005/5/20
2005/5/21
ACTUAL -
2005/5/29
2005/5/30
2005/5/31
2005/6/1
2005/6/2
2005/6/3
2005/6/4
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* Created on 2005-05-30
*/
import java.util.Calendar;
/**
* @author Jean-Sebastien Goupil
*/
public class Testing {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 20);
cal.set(Calendar.MONTH, 4);
cal.set(Calendar.YEAR, 2005);
// Uncomment this next line to have a correct behaviour
//cal.get(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
for (int i = 0; i < 7; i++) {
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
System.out.println(year + "/" + month + "/" + day);
cal.add(Calendar.DAY_OF_MONTH, 1);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Uncomment the following line :
//cal.get(Calendar.DAY_OF_MONTH);
and it seems to work for now.
###@###.### 2005-06-22 09:02:02 GMT
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000
Service Pack 4
A DESCRIPTION OF THE PROBLEM :
When trying to display dates, there is a problem if we don't do a get before a set of a weekday of Calendar instance. It returns the first week of the month instead of the one selected by the day.
By executing this code in debug mode, everything seems to work well.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the code in test case with and without the comment
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2005/5/15
2005/5/16
2005/5/17
2005/5/18
2005/5/19
2005/5/20
2005/5/21
ACTUAL -
2005/5/29
2005/5/30
2005/5/31
2005/6/1
2005/6/2
2005/6/3
2005/6/4
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* Created on 2005-05-30
*/
import java.util.Calendar;
/**
* @author Jean-Sebastien Goupil
*/
public class Testing {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 20);
cal.set(Calendar.MONTH, 4);
cal.set(Calendar.YEAR, 2005);
// Uncomment this next line to have a correct behaviour
//cal.get(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
for (int i = 0; i < 7; i++) {
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
System.out.println(year + "/" + month + "/" + day);
cal.add(Calendar.DAY_OF_MONTH, 1);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Uncomment the following line :
//cal.get(Calendar.DAY_OF_MONTH);
and it seems to work for now.
###@###.### 2005-06-22 09:02:02 GMT
- relates to
-
JDK-4860664 REGRESSION:Calendar get(Calendar.DAY_OF_WEEK)invalid under certain circumstances
-
- Resolved
-