You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "spark shen (JIRA)" <ji...@apache.org> on 2006/09/26 07:50:52 UTC
[jira] Commented: (HARMONY-947)
GregorianCalendar.getLeastMaximim(int) returns values that differ from RI
[ http://issues.apache.org/jira/browse/HARMONY-947?page=comments#action_12437746 ]
spark shen commented on HARMONY-947:
------------------------------------
Hi Anton:
I totally agree with you. And I found the historical reasons behind these magic number :-). Listed below:
wrong value at 3: expected 52, got 50 Pope Gregory XIII decreed that the day after October 4, 1582 would be October 15, 1582 [http://scienceworld.wolfram.com/]
wrong value at 4: expected 3, got 4 index 4 here means WEEK_OF_MONTH [RI5.0 spec]. Due the reason above, October, 1582 has only 3 weeks.
wrong value at 6: expected 355, got 365 index 6 here means DAY_OF_YEAR [RI5.0 spec]. Due the reason above, 1582 has only 355 days.
wrong value at 8: expected 3, got 4 index 8 here means DAY_OF_WEEK_IN_MONTH. Due the reason above, October, 1582 has only 3 weeks. So, the max DAY_OF_WEEK_IN_MONTH value of this particular month is 3.
wrong value at 15: expected 50400000, got 43200000: index 15 here stands for ZONE_OFFSET. 50400000 can be converted into 14 hours, while 43200000 is 12. 14 is legal according to [1].
wrong value at 16: expected 1200000, got 3600000: index 16 here stands for DST_OFFSET. "but adjustments of 20, 40 minutes have also been used"[2]
[1]:http://wwp.greenwichmeantime.com/info/timezone.htm
[2]:http://www.timeanddate.com/time/aboutdst.html
So, +1 for your patch.
Best regards
> GregorianCalendar.getLeastMaximim(int) returns values that differ from RI
> -------------------------------------------------------------------------
>
> Key: HARMONY-947
> URL: http://issues.apache.org/jira/browse/HARMONY-947
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: Windows XP Professional
> Reporter: Anton Luht
> Priority: Minor
> Attachments: patch.txt
>
>
> Harmony classlib + DRLVM 424264
> Values that are returned by Calendar.getLeastMaximum(int) differ from RI. The following code shows it:
> import java.util.*;
> public class Test {
> public static void main(String args[]) {
> String localVariable0 = "PST";
> TimeZone localTimeZone = TimeZone.getTimeZone(localVariable0);
> Calendar localCalendar = Calendar.getInstance(localTimeZone);
>
> int[] max = { 1, 292269054, 11, 50, 3, 28, 355, 7, 3, 1, 11, 23, 59,
> 59, 999, 50400000, 1200000 };
> for (int i = 0; i < max.length; i++) {
> if (localCalendar.getLeastMaximum(i) != max[i]) {
> System.err.println("wrong value at " + i + ": expected " + max[i] + ", got " + localCalendar.getLeastMaximum(i));
> }
> }
> }
> }
> On RI it prints nothing, on Harmony it prints:
> wrong value at 3: expected 52, got 50
> wrong value at 4: expected 3, got 4
> wrong value at 6: expected 355, got 365
> wrong value at 8: expected 3, got 4
> wrong value at 15: expected 50400000, got 43200000
> wrong value at 16: expected 1200000, got 3600000
> I do not understand quite well how can 50-week year happen, maybe it was the year when dates shifted, but anyway - for compatibility with RI it's better for that function to return same values.
> Please see the patch to junit test and classlib code attached
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira