Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4623997

GregorianCalendar returns bad WEEK_OF_YEAR

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.1
    • 1.3.0, 1.4.0
    • core-libs
    • hopper
    • x86, sparc
    • solaris_8, windows_nt



        Name: jk109818 Date: 01/15/2002


        FULL PRODUCT VERSION :
        java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
        OJVM Client VM (build 5.0.438 cdov, Copyright (c) 1998-2001 Oracle corp.,
        nojit)

        FULL OPERATING SYSTEM VERSION :
        Microsoft Windows NT 4.00.1381



        A DESCRIPTION OF THE PROBLEM :
        get(GregorianCalendar.WEEK_OF_YEAR) for days 1.1.2000
        and 1.1.1999 returns value 1, but it should be 52 (53).

        2.1.2000 and 2.1.1999 returns right value 52 (53).

        It works incorrectly only in a special case - see source
        code.

        This bug can be reproduced always.

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

        GregorianCalendar cal = new GregorianCalendar(2000, GregorianCalendar.JANUARY,
        1);

        cal.get(GregorianCalendar.DAY_OF_WEEK); // this line must be here

        cal.setFirstDayOfWeek(GregorianCalendar.MONDAY);
        cal.setMinimalDaysInFirstWeek(4);

        System.out.println(cal.get(GregorianCalendar.WEEK_OF_YEAR));
                 // writes "1", but it should be "52"

        ---------- END SOURCE ----------
        (Review ID: 138299)
        ======================================================================

              okutsu Masayoshi Okutsu
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: