-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.2
-
x86
-
windows_2000
Name: jl125535 Date: 11/07/2003
FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b26)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b26, mixed mode)
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
SunOS burns 5.8 Generic_108528-18 sun4u sparc SUNW,UltraAX-i2
A DESCRIPTION OF THE PROBLEM :
getActualMaximum returns an incorrect value for DAY_OF_WEEK_IN_MONTH,
if called after setting year/month/day_of_month (any), but before calling
getActualMaximum( DAY_OF_MONTH ), which somehow "fixes" the situation
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the test program, which creates a GregorianCalendar, then sets the date/time
using set(field,value) to a day that will occur in 5 unshifted weeks in a the month, call getActualMaximum( DAY_OF_WEEK_IN_MONTH ). the value will be incorrect, after calling getActualMaximum( DAY_OF_MONTH ), again calling for
DAY_OF_WEEK_IN_MONTH will now be correct..
seems that getActualMaximum( DAY_OF_MONTH ) a call to complete() and/or
other protected initializing methods which cause the values to be correctly determined, whereas the execution path for DAY_OF_WEEK_IN_MONTH does not.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Sat Aug 02 13:01:01 EDT 2003
actual maximum (1st): 5
day of month Maximum: 31
actual maximum (2nd): 5
ACTUAL -
Sat Aug 02 13:01:01 EDT 2003
actual maximum (1st): 4
day of month Maximum: 31
actual maximum (2nd): 5
notice it 1st reports 4 (wrong), then 5 (correct)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
public class Test
{
public static void main( String[] args )
{
Calendar cal = new GregorianCalendar();
// august 2nd 2003.
cal.set( Calendar.YEAR, 2003 );
cal.set( Calendar.MONTH, 7 );
cal.set( Calendar.DAY_OF_MONTH, 2 );
cal.set( Calendar.HOUR, 1 );
cal.set( Calendar.MINUTE, 1 );
cal.set( Calendar.SECOND, 1 );
cal.set( Calendar.MILLISECOND, 1 );
System.out.println( cal.getTime() );
int dowim1 = cal.getActualMaximum( Calendar.DAY_OF_WEEK_IN_MONTH );
int dom = cal.getActualMaximum( Calendar.DAY_OF_MONTH );
int dowim2 = cal.getActualMaximum( Calendar.DAY_OF_WEEK_IN_MONTH );
System.out.println( "actual maximum (1st): " + dowim1 );
System.out.println( "day of month Maximum: " + dom );
System.out.println( "actual maximum (2nd): " + dowim2 );
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
calling getActualMaximum( DAY_OF_MONTH )
may be others, but this call certainly does make the other work.
(Incident Review ID: 194027)
======================================================================
- duplicates
-
JDK-4916815 REGRESSION: Problem with java.util.Calendar VM 1.4.2-b28
-
- Resolved
-