classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug report: java.util.GregorianCalendar


From: Mark Wielaard
Subject: Re: Bug report: java.util.GregorianCalendar
Date: Thu, 28 Aug 2003 00:21:23 +0200

Hi,

On Mon, 2003-07-28 at 07:43, Ito Kazumitsu wrote:
> Sun's API document says about java.util.Calendar.WEEK_OF_MONTH,
> "The first week of the month, as defined by getFirstDayOfWeek() and
> getMinimalDaysInFirstWeek(), has value 1."
> 
> But GNU Classpath's java.util.GregorianCalendar returns 0 for the
> first week of the month except for those special months whose
> first day is Sunday (e.g. Jun 2003).
> 
> Here is my patch:

Thanks. I finally looked into this.
I created a simple Mauve test case for this (attached), but even with
your patch it still gives a few failures.

FAIL: gnu.testlet.java.util.GregorianCalendar.first: 1-3-2000 (number 1)
got 2 but expected 1
FAIL: gnu.testlet.java.util.GregorianCalendar.first: 1-6-2000 (number 1)
got 2 but expected 1
FAIL: gnu.testlet.java.util.GregorianCalendar.first: 1-4-2004 (number 1)
got 2 but expected 1
FAIL: gnu.testlet.java.util.GregorianCalendar.first: 1-12-2004 (number 1)
got 2 but expected 1
4 of 72 tests failed

Could you see if my test or GregorianCalendar is faulty?

Thanks,

Mark
// Tags: JDK1.1

// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Mark Wielaard (address@hidden)

// This file is part of Mauve.

// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.

// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING.  If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.

package gnu.testlet.java.util.GregorianCalendar;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import java.util.*;

/**
 * Checks that the first week of the month is week one.
 */
public class first implements Testlet
{
  public void test (TestHarness harness)
  {
    for (int year = 2000; year <= 2005; year++)
      for (int month = 1; month <= 12; month++)
        {
          GregorianCalendar cal = new GregorianCalendar(year, month, 1);
          harness.check(cal.get(Calendar.WEEK_OF_MONTH), 1,
                        1 + "-" + month + "-" + year);
        }
  }
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]