Patch: GregorianCalendar returns bad values from getMinimum().

Andrew John Hughes
Sun Feb 6 19:04:00 GMT 2005

On Sun, 2005-02-06 at 15:11 +0100, Sven de Marothy wrote:
> Hi,
> Yes, I included David's fix in my most recent patch. But in the context
> of how much was and is broken with GregorianCalendar, it's a minor bug.
> I don't see why you're discussing this. You should merge in the
> Classpath versions of these classes ASAP and perhaps close some of those
> related Bugzilla bugs.
> > > There are a few changes in Classpath that are not reflected in libgcj, 
> > > however I wouldn't call it a rewrite. Someone has gone and rather 
> > > gratuitously reformatted a bunch of code and created a lot of diffs, but 
> > > there's only a few significant code changes. 
> Well, my only comment is that I feel the changes were significant. The
> old code was broken in nearly every way. There were also what appear to
> be ad-hoc 'fixes' introduced into the code, which didn't really fix
> things. 
> Leniency basically did not work correctly at all. Pre-gregorian-cutover
> (1582) dates were all wrong. The cutover itself was not handled
> correctly. The BC-AD transition was wrong. The day of week was incorrect
> for all dates prior to the epoch (1970). Handling of time-zones was
> correct in some places and incorrect in others. Handling of insufficient
> data was incorrect. Nonlenient checking wasn't working in all cases.
> Clearing the calendar resulted in the wrong values. The priority order
> of fields was wrong. Etc. The code had No, it's not a complete rewrite,
> but in hindsight that would've been easier, giving the time I spent
> trying to figure out how the broken code was supposed to work before
> realizing it couldn't work.
> I also removed several commented-out methods, redundant methods, and
> some confusingly similar methods (getLinearDay()/getLinearTime()).
> The remaining bugs I know of is that minimumDaysInFirstWeek and
> firstDayOfWeek handling isn't implemented. I'm working on that. There
> may be bugs in the roll methods too, I haven't tested them yet.
> /Sven

I just want to second what Sven says here.  The Calendar and TimeZone
implementations, prior to the series of patches referenced by Mark, were
buggy and unreliable to say the least.  Looking at the patches, the size
of the actual code changes may appear minor, but the effect of these
changes is much clearer; they actually make these classes USABLE.

I've been working with the java.text.SimpleDateFormat class, which
relies heavily on these classes to operate (the class simply handles the
external processes of input parsing and output formatting, all date
calculation is completed by the Calendar and TimeZone implementations).
Doing so revealed some of the bugs which Sven has dedicated a lot of his
time to solving (the patches, in all, constitute almost a complete
re-write).  To give a metric for this change, you only have to look at
the Mauve testcases for parsing dates using SimpleDateFormat.  When I
first looked at this, it had 20 test cases, 18 of which failed.  It now
has 21 (I added one from a bug in our database), and all of these pass.
This is as a direct result of the Calendar/TimeZone changes and my own
fixes to this class.  Just as with the Calendar classes, there are no
doubt still bugs in this class (I particularly want to look at the
format side of things now), but these changes do go a long way to
achieving a usable date system for our library.

As a result, I think these definitely need to go into libgcj.  They
solve quite a few bugs that have occurred in both Classpath and libgcj's
bug databases, and, for one, I'm not particularly keen on seeing these
constantly reoccurring in the new release version.  If the indenting
changes are a problem, then Sven made these in a separate patch so this
could be avoided.  With respect to indenting, many of the classes are
quite simply a mess, and no doubt a few of these changes have crept into
my own patches in the past.  It's a temptation that's hard to resist.

Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint)

No software patents in Europe --

"Value your freedom, or you will lose it, teaches history. 
`Don't bother us with politics' respond those who don't want to learn." 
-- Richard Stallman

"We've all been part of the biggest beta test the world has ever known
-- Victor Wheatman, Gartner

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Java-patches mailing list