[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug report: java.util.GregorianCalendar
From: |
Ito Kazumitsu |
Subject: |
Re: Bug report: java.util.GregorianCalendar |
Date: |
Fri, 29 Aug 2003 15:58:38 +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) |
In message "Re: Bug report: java.util.GregorianCalendar"
on 03/08/28, Ito Kazumitsu <address@hidden> writes:
> And I have found another bug shown by the attached program.
> This bug seems to have something to do with leap yeas.
> If this bug is fixed, my patch about the WEEK_OF_MONTH will
> work.
This is my patch for this bug.
--- java/util/GregorianCalendar.java.orig Thu Aug 14 13:32:06 2003
+++ java/util/GregorianCalendar.java Fri Aug 29 15:56:51 2003
@@ -264,8 +264,10 @@
//
// The additional leap year factor accounts for the fact that
// a leap day is not seen on Jan 1 of the leap year.
+ // And on and after the leap day, the leap day has already been
+ // included in dayOfYear.
int gregOffset = (year / 400) - (year / 100) + 2;
- if (isLeapYear (year, true) && dayOfYear < 31 + 29)
+ if (isLeapYear (year, true))
--gregOffset;
time += gregOffset * (24 * 60 * 60 * 1000L);
}
@@ -609,7 +611,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;