You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Elena Sayapina (JIRA)" <ji...@apache.org> on 2007/07/10 14:38:04 UTC
[jira] Commented: (HARMONY-4372) [classlib][luni]
GregorianCalendar.roll() works incorrectly around end of year if
MinimalDaysInFirstWeek is 4
[ https://issues.apache.org/jira/browse/HARMONY-4372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12511410 ]
Elena Sayapina commented on HARMONY-4372:
-----------------------------------------
Hello, Tony,
The test from this bug passed on Harmony-r554868.
But I slightly changed the test, added roll back to initial date, and expected that it rolls back, but it didn't
Correct me if I missed something and please, see updated test:
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
public class rollTest {
static GregorianCalendar calendar = new GregorianCalendar(Locale.UK);
static GregorianCalendar pattern = new GregorianCalendar(Locale.UK);
public static void main(String[] args) {
calendar.set(1994, 11, 30, 0, 0, 0);
pattern.set(1994, 11, 30, 0, 0, 0);
System.out.println("MinimalDaysInFirstWeek: " + calendar.getMinimalDaysInFirstWeek());
System.out.println("Initial date: " + calendar.getTime());
calendar.roll(Calendar.WEEK_OF_YEAR, true);
System.out.println("Roll ahead by WEEK_OF_YEAR: " + calendar.getTime());
calendar.roll(Calendar.WEEK_OF_YEAR, false);
System.out.println("Roll back by WEEK_OF_YEAR: " + calendar.getTime());
if (calendar.equals(pattern)) System.out.println("TEST PASSED");
else System.out.println("TEST FAILED");
}
}
Output on Harmony-r554868:
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r554868, (Jul 10 2007), Windows/ia32/msvc 1310, release build
http://harmony.apache.org
MinimalDaysInFirstWeek: 4
Initial date: Fri Dec 30 00:00:00 NOVT 1994
Roll ahead by WEEK_OF_YEAR: Fri Jan 07 00:00:00 NOVT 1994
Roll back by WEEK_OF_YEAR: Fri Jan 07 00:00:00 NOVT 1994
TEST FAILED
Output on RI:
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
MinimalDaysInFirstWeek: 4
Initial date: Fri Dec 30 00:00:00 NOVT 1994
Roll ahead by WEEK_OF_YEAR: Fri Jan 07 00:00:00 NOVT 1994
Roll back by WEEK_OF_YEAR: Fri Dec 30 00:00:00 NOVT 1994
TEST PASSED
> [classlib][luni] GregorianCalendar.roll() works incorrectly around end of year if MinimalDaysInFirstWeek is 4
> -------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-4372
> URL: https://issues.apache.org/jira/browse/HARMONY-4372
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Elena Sayapina
> Assignee: Tony Wu
> Priority: Minor
>
> GregorianCalendar.roll() works incorrectly around end of year if MinimalDaysInFirstWeek is 4
> Please, consider the following code:
> import java.util.Calendar;
> import java.util.GregorianCalendar;
> import java.util.Locale;
> public class rollTest {
> static GregorianCalendar calendar = new GregorianCalendar(Locale.UK);
> static GregorianCalendar pattern = new GregorianCalendar(Locale.UK);
>
> public static void main(String[] args) {
> calendar.set(1994, 11, 30, 0, 0, 0);
> pattern.set(1994, 0, 7, 0, 0, 0);
> System.out.println("MinimalDaysInFirstWeek: " + calendar.getMinimalDaysInFirstWeek());
> System.out.println("Initial date: " + calendar.getTime());
> calendar.roll(Calendar.WEEK_OF_YEAR, true);
> System.out.println("Roll ahead by WEEK_OF_YEAR: " + calendar.getTime());
> if (calendar.equals(pattern)) System.out.println("TEST PASSED");
> else System.out.println("TEST FAILED");
> }
> }
> Output on Harmony-r553727:
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
> as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r553727, (Jul 6 2007), Windows/ia32/msvc 1310, release build
> http://harmony.apache.org
> MinimalDaysInFirstWeek: 4
> Initial date: Fri Dec 30 00:00:00 NOVT 1994
> Roll ahead by WEEK_OF_YEAR: Sat Dec 31 00:00:00 NOVT 1994
> TEST FAILED
> Output on RI:
> java version "1.5.0_11"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
> MinimalDaysInFirstWeek: 4
> Initial date: Fri Dec 30 00:00:00 NOVT 1994
> Roll ahead by WEEK_OF_YEAR: Fri Jan 07 00:00:00 NOVT 1994
> TEST PASSED
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.