JDK-5067758 : invalid result of Calendar.getActualMaximum(Calendar.WEEK_OF_MONTH) method
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux
  • CPU: x86
  • Submitted: 2004-06-24
  • Updated: 2004-06-27
  • Resolved: 2004-06-27
Related Reports
Relates :  
Description

Name: js151677			Date: 06/24/2004


FULL PRODUCT VERSION :
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux potenilla 2.6.5-1.358.8kstacks #1 Sat May 22 21:46:42 EDT 2004 i686 athlon i386 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
not important in this case

A DESCRIPTION OF THE PROBLEM :
For Calendar with week that starts with monday (i.e. locale pl_PL) the method getActualMaximum(WEEK_OF_MONTH) produces invalid result (4) for february 2004.
This month has 29 days.
The bug appears in following vm versions:
1.4.2-b28, 1.4.2_04-b05, 1.5.0-beta2-b51
in version 1.4.1-b21 the result (5) was correct.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see the source code


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;

public class CalendarTest
{
    public static void main(String[] argv)
    {
    	Calendar calendar = Calendar.getInstance(new Locale("pl", "PL"));
    	calendar.set(Calendar.YEAR, 2004);
    	calendar.set(Calendar.MONTH, 1);
    	System.out.println("vm version: "+ System.getProperty("java.vm.version"));
    	System.out.println("current time: "+calendar.getTime());
    	System.out.println("weeks in feb 2004: "+
            calendar.getActualMaximum(Calendar.WEEK_OF_MONTH));
    }
}
---------- END SOURCE ----------
(Incident Review ID: 281290) 
======================================================================

Comments
EVALUATION 4 should be the correct value since the first day of week is Monday and the minimal days in the first week is 4 in the pl_PL locale. The first week starts from the 2nd. The week of 23 is the 4th week. The minimal days in the first week value in pl locale was fixed in 1.4.2. See 4518811. ###@###.### 2004-06-26
26-06-2004