From: "Jeroen Frijters" <jeroen@sumatra.nl>
To: "Michael Koch" <konqueror@gmx.de>, <classpath@gnu.org>
Cc: "Mauve Discuss" <mauve-discuss@sources.redhat.com>
Subject: RE: java.util.Date mess
Date: Tue, 12 Oct 2004 09:35:00 -0000 [thread overview]
Message-ID: <D92197D0A6547B44A1567814F851FA687E1C@LEMBU.sumatrasoftware.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 940 bytes --]
Michael Koch wrote:
> On Monday 11 October 2004 15:39, Jeroen Frijters wrote:
> > I have some code that depends on unspecified behavior of
> > java.util.Date. In the Sun JDK if you pass out of range parameters
> > to the Date constructors that take year, month, date, etc. it will
> > automatically convert to a valid date (for example, new Date(104,
> > 8, 41) is Oct 11, 2004.)
> >
> > I have a rather lame patch that addresses this (see below), would
> > anyone object to this?
>
> Are there mauve test that confirm that this breaks nothing ?
I made a new Mauve test (attached) that works better with my patch
(after I fixed one error in my patch and fixed an additional Date bug),
but it still fails on three tests. One is due to a bug in
GregorianCalendar and I haven't investigated the other two.
Is the attached test OK to commit? Do I need to modify any other Mauve
files to add the test?
Regards,
Jeroen
[-- Attachment #2: range.java --]
[-- Type: application/octet-stream, Size: 2052 bytes --]
// Tags: JDK1.0
// Copyright (C) 2004 Free Software Foundation, Inc.
// Contributed by Jeroen Frijters <jeroen@frijters.net>.
// 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.Date;
import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import java.util.Date;
public class range implements Testlet
{
private TestHarness harness;
public void test (TestHarness harness)
{
this.harness = harness;
check(70, 0, 1, 0, 0, 0, 0);
check(104, 9, 12, 0, 0, 0, 1097539200000L);
check(104, 9, 12, 0, 0, 0, 1097539200000L);
check(104, 9, 12, 12, 34, 0, 1097584440000L);
check(104, 9, 12, 12, 34, 56, 1097584496000L);
check(104, -1, 0, 0, 0, 0, 1070150400000L);
check(104, 99, 99, 99, 99, 99, 1342068039000L);
check(104, 999, 999, 999, 999, 999, 3785583171704L);
check(104, -1, -1, -1, -1, -1, 1070060339000L);
check(104, -999, -999, -999, -999, -999, -1640011971704L);
}
private void check(int year, int month, int day, int hours, int mins, int secs, long l)
{
try
{
Date d = new Date(year, month, day, hours, mins, secs);
harness.check(d.getTime() - d.getTimezoneOffset() * 60 * 1000 == l);
}
catch (Throwable t)
{
harness.debug(t);
harness.check(false);
}
}
}
next reply other threads:[~2004-10-12 9:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-12 9:35 Jeroen Frijters [this message]
2004-10-12 9:41 ` Andrew Haley
2004-10-12 9:41 ` Michael Koch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D92197D0A6547B44A1567814F851FA687E1C@LEMBU.sumatrasoftware.com \
--to=jeroen@sumatra.nl \
--cc=classpath@gnu.org \
--cc=konqueror@gmx.de \
--cc=mauve-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).