harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov" <mikhail.a.mar...@gmail.com>
Subject Re: [classlib][luni]strange problem of GregorianCalendar on RI
Date Mon, 15 Jan 2007 09:16:15 GMT
Tony,

There are clearly some problems with RI in GregorianCalendar class.
Also I've played a bit with your code and got interesting result if i swap 3
& 4 lines:
365
30
11
2000
53
353
50
50

IMHO we should act as described by the spec and file "non-bug difference"
against RI.

Regards,
Mikhail


On 1/15/07, Tony Wu <wuyuehao@gmail.com> wrote:
>
> Hi all,
> These days I'm struggling on fixing bugs of GregorainCalendar. I found
> strange behavior of RI.
>
>        Date date = new Date(Date.parse("Feb 28 00:00:01 GMT 2000"));
>        GregorianCalendar gc = new GregorianCalendar();
>        gc.setGregorianChange(date);
>        gc.setTimeInMillis(Date.parse("Dec 30 00:00:01 GMT 2000"));
>        System.out.println(gc.get(Calendar.DAY_OF_YEAR));
>        System.out.println(gc.get(Calendar.DAY_OF_MONTH));
>        System.out.println(gc.get(Calendar.MONTH));
>        System.out.println(gc.get(Calendar.YEAR));
>        System.out.println(gc.get(Calendar.WEEK_OF_YEAR));
>        System.out.println(gc.getActualMaximum(Calendar.DAY_OF_YEAR));
>        System.out.println(gc.getActualMaximum(Calendar.WEEK_OF_YEAR));
>        System.out.println(gc.getLeastMaximum(Calendar.WEEK_OF_YEAR));
>
> RI's output:
>
> 352
> 30
> 11
> 2000
> 51
> 353
> 50
> 50
>
> According to spec, getActualMaximum should return the possiblely
> maximun value of the given field. In testcase below, the actual
> maximum DAY_OF_YEAR is 353 whereas the the actual maximum WEEK_OF_YEAR
> is 50. It is impossible that a year with 353 days contains only 50
> weeks.(the FirstDayOfWeek is Sunday and the MinimalDaysInFirstWeek is
> 1).
>
> What is the more unbelievable is that the
> gc.get(Calendar.WEEK_OF_YEAR) returns 51 whereas
> gc.getActualMaximum(Calendar.WEEK_OF_YEAR) returns 50.  That is the
> "Dec 30" is the 51st week of 2000, however, the 2000 contains 50 weeks
> at most?
>
> I'm confused, do you have any concern?
> --
> Tony Wu
> China Software Development Lab, IBM
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message