You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Chen Shunfei (JIRA)" <ji...@apache.org> on 2007/10/09 04:31:50 UTC
[jira] Updated: (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:all-tabpanel ]
Chen Shunfei updated HARMONY-4907:
----------------------------------
Summary: [classlib][luni] Calendar.get(Calendar.WEEK_OF_MONTH) returns wrong value (was: [classlib][luni] Calendar.get(Calendar.WEEK_OF_MONTH))
> [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
>
> 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.