public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libgcj/6045: GregorianCalendar: getMinimum() and getMaximum() incorrect for month
@ 2002-03-22 17:36 msmith
0 siblings, 0 replies; 3+ messages in thread
From: msmith @ 2002-03-22 17:36 UTC (permalink / raw)
To: gcc-gnats
>Number: 6045
>Category: libgcj
>Synopsis: GregorianCalendar: getMinimum() and getMaximum() incorrect for month
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 22 17:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Michael Smith
>Release: gcj (GCC) 3.1 20020322 (prerelease)
>Organization:
>Environment:
Linux msmith 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown
>Description:
The Java API specification for Calendar describe Months as zero-based. That means that getMinimum(Calendar.MONTH) should return 0. However, gcj is reporting 1. It would probably be ok for gcj to report 1 if it actually used 1 based months, but it's using 0 based months and still reporting 1 for getMinimum. Same problems with getMaximum (11 vs 12).
>How-To-Repeat:
[msmith@msmith cal]$ cat MonthMin.java
import java.util.Date;
import java.util.Calendar;
public class MonthMin {
public static void main(String args[]) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int monthMin = cal.getMinimum(Calendar.MONTH);
System.err.println("Minimum value for month: " + monthMin);
// set the month to the minimum
cal.set(Calendar.MONTH, monthMin);
System.err.println("Month in this timestamp should be January: " +
cal.getTime());
}
}
[msmith@msmith cal]$ java -version
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
[msmith@msmith cal]$ javac MonthMin.java
[msmith@msmith cal]$ java MonthMin
Minimum value for month: 0
Month in this timestamp should be January: Tue Jan 22 20:23:35 EST 2002
[msmith@msmith cal]$ gcj --version
gcj (GCC) 3.1 20020322 (prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[msmith@msmith cal]$ gcj --main=MonthMin -o MonthMin MonthMin.java
[msmith@msmith cal]$ ./MonthMin
Minimum value for month: 1
Month in this timestamp should be January: Fri Feb 22 20:23:57 GMT-05:00 2002
>Fix:
Index: GregorianCalendar.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/GregorianCalendar.java,v
retrieving revision 1.15
diff -u -r1.15 GregorianCalendar.java
--- GregorianCalendar.java 2002/01/22 22:40:38 1.15
+++ GregorianCalendar.java 2002/03/23 01:30:31
@@ -917,11 +917,11 @@
}
private static final int[] minimums =
- { BC, 1, 1, 0, 1, 1, 1, SUNDAY, 1,
+ { BC, 1, 0, 0, 1, 1, 1, SUNDAY, 1,
AM, 1, 0, 1, 1, 1, -(12*60*60*1000), 0 };
private static final int[] maximums =
- { AD, 5000000, 12, 53, 5, 31, 366, SATURDAY, 5,
+ { AD, 5000000, 11, 53, 5, 31, 366, SATURDAY, 5,
PM, 12, 23, 59, 59, 999, +(12*60*60*1000), (12*60*60*1000) };
/**
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libgcj/6045: GregorianCalendar: getMinimum() and getMaximum() incorrect for month
@ 2002-03-23 19:26 Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2002-03-23 19:26 UTC (permalink / raw)
To: tromey; +Cc: gcc-prs
The following reply was made to PR libgcj/6045; it has been noted by GNATS.
From: Tom Tromey <tromey@redhat.com>
To: msmith@spinnakernet.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libgcj/6045: GregorianCalendar: getMinimum() and getMaximum() incorrect for month
Date: 23 Mar 2002 09:40:03 -0700
>>>>> "Michael" == Michael Smith <msmith@spinnakernet.com> writes:
Michael> The Java API specification for Calendar describe Months as
Michael> zero-based. That means that getMinimum(Calendar.MONTH)
Michael> should return 0. However, gcj is reporting 1. It would
Michael> probably be ok for gcj to report 1 if it actually used 1
Michael> based months, but it's using 0 based months and still
Michael> reporting 1 for getMinimum. Same problems with getMaximum
Michael> (11 vs 12).
Thanks for the report and the patch. I agree this is correct, and
I'll check it in shortly.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libgcj/6045: GregorianCalendar: getMinimum() and getMaximum() incorrect for month
@ 2002-03-23 8:11 tromey
0 siblings, 0 replies; 3+ messages in thread
From: tromey @ 2002-03-23 8:11 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, java-prs, msmith, nobody, tromey
Synopsis: GregorianCalendar: getMinimum() and getMaximum() incorrect for month
Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Sat Mar 23 08:11:34 2002
Responsible-Changed-Why:
I'm handling the PR.
State-Changed-From-To: open->closed
State-Changed-By: tromey
State-Changed-When: Sat Mar 23 08:11:34 2002
State-Changed-Why:
I'm checking in the patch.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6045
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-03-24 3:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-22 17:36 libgcj/6045: GregorianCalendar: getMinimum() and getMaximum() incorrect for month msmith
2002-03-23 8:11 tromey
2002-03-23 19:26 Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).