You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Oliver Deakin (JIRA)" <ji...@apache.org> on 2010/03/23 18:08:27 UTC
[jira] Commented: (HARMONY-4907) [classlib][luni]
Calendar.get(Calendar.WEEK_OF_MONTH) returns wrong value
[ https://issues.apache.org/jira/browse/HARMONY-4907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12848804#action_12848804 ]
Oliver Deakin commented on HARMONY-4907:
----------------------------------------
Hi Ramana - applying this patch causes one failure for me in CalendarTest.test_clear():
junit.framework.AssertionFailedError: Field 5 Should equal to 20. expected:<20> but was:<13>
at org.apache.harmony.luni.tests.java.util.CalendarTest.test_clear(CalendarTest.java:605)
at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
> [classlib][luni] Calendar.get(Calendar.WEEK_OF_MONTH) returns wrong value
> -------------------------------------------------------------------------
>
> Key: HARMONY-4907
> URL: https://issues.apache.org/jira/browse/HARMONY-4907
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: harmony-jre-579330
> WindowXP
> Reporter: Chen Shunfei
> Assignee: Tony Wu
> Priority: Trivial
> Attachments: GregorianCalendar.patch
>
>
> Here is the testcase:
> import java.util.Calendar;
> import java.util.GregorianCalendar;
> import junit.framework.TestCase;
> public class Test extends TestCase {
> public void testDayOfWeekInMonth() {
> GregorianCalendar c = new GregorianCalendar();
> int minimalDaysInFirstWeek = 2;
> int firstDayOfWeek = Calendar.SUNDAY;
> c.setFirstDayOfWeek(firstDayOfWeek);
> int month = Calendar.DECEMBER;
> int year = 2007;
> int day = 1;
> c.set(year, month, day);
> int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
> int relativeDayOfWeek = (7 + dayOfWeek - firstDayOfWeek) % 7;
> int relativeDayOfFirst = (relativeDayOfWeek - day + 1 + 35) % 7;
> int weekOfFirst = ((7 - relativeDayOfFirst) >= minimalDaysInFirstWeek) ? 1
> : 0;
> int weekOfMonth = (day + relativeDayOfFirst - 1) / 7 + weekOfFirst;
> assertEquals(c.get(Calendar.WEEK_OF_MONTH), weekOfMonth);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.