classpath
[Top][All Lists]
Advanced

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

Bug report: java.util.GregorianCalendar


From: Ito Kazumitsu
Subject: Bug report: java.util.GregorianCalendar
Date: Mon, 28 Jul 2003 14:43:50 +0900
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (Unebigory ōmae) APEL/10.3 Emacs/20.7 (i386-*-windows98.2222) MULE/4.1 (AOI) Meadow/1.14 (AWSAKA:62)

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:

--- java/util/GregorianCalendar.java.orig       Sun Mar 24 01:10:15 2002
+++ java/util/GregorianCalendar.java    Mon Jul 28 11:53:16 2003
@@ -599,7 +599,7 @@
     // which day of the week are we (0..6), relative to getFirstDayOfWeek
     int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7;
 
-    fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 6) / 7;
+    fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7;
 
     int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7;
 

By the way,  while GNU Classpath's Calendar returns 53 or 54 as the last
week of the year,  Sun's Java 1.4.2 returns 1.  I think this may be a bug
of Sun's.




reply via email to

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