gt:             int dowValue = dayOfWeek.get(millis);
context: /*
   *  Copyright 2001-2013 Stephen Colebourne
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.joda.time.chrono;
  
  import java.util.Locale;
  import java.util.TimeZone;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  import org.joda.time.Chronology;
  import org.joda.time.DateTime;
  import org.joda.time.DateTimeConstants;
  import org.joda.time.DateTimeField;
  import org.joda.time.DateTimeUtils;
  import org.joda.time.DateTimeZone;
  import org.joda.time.DurationField;
  import org.joda.time.DurationFieldType;
  import org.joda.time.DateTime.Property;
  
  /**
   * This class is a Junit unit test for EthiopicChronology.
   *
   * @author Stephen Colebourne
   */
  public class TestEthiopicChronology extends TestCase {
  
      private static final int MILLIS_PER_DAY = DateTimeConstants.MILLIS_PER_DAY;
  
      private static long SKIP = 1 * MILLIS_PER_DAY;
  
      private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
      private static final DateTimeZone LONDON = DateTimeZone.forID("Europe/London");
      private static final DateTimeZone TOKYO = DateTimeZone.forID("Asia/Tokyo");
      private static final Chronology ETHIOPIC_UTC = EthiopicChronology.getInstanceUTC();
      private static final Chronology JULIAN_UTC = JulianChronology.getInstanceUTC();
      private static final Chronology ISO_UTC = ISOChronology.getInstanceUTC();
  
      long y2002days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 
                       366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 
                       365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 +
                       366 + 365;
      // 2002-06-09
      private long TEST_TIME_NOW =
              (y2002days + 31L + 28L + 31L + 30L + 31L + 9L -1L) * MILLIS_PER_DAY;
  
      private DateTimeZone originalDateTimeZone = null;
      private TimeZone originalTimeZone = null;
      private Locale originalLocale = null;
  
      public static void main(String[] args) {
          junit.textui.TestRunner.run(suite());
      }
  
      public static TestSuite suite() {
          SKIP = 1 * MILLIS_PER_DAY;
          return new TestSuite(TestEthiopicChronology.class);
      }
  
      public TestEthiopicChronology(String name) {
          super(name);
      }
  
      protected void setUp() throws Exception {
          DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
          originalDateTimeZone = DateTimeZone.getDefault();
          originalTimeZone = TimeZone.getDefault();
          originalLocale = Locale.getDefault();
          DateTimeZone.setDefault(LONDON);
          TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
          Locale.setDefault(Locale.UK);
      }
  
      protected void tearDown() throws Exception {
          DateTimeUtils.setCurrentMillisSystem();
          DateTimeZone.setDefault(originalDateTimeZone);
          TimeZone.setDefault(originalTimeZone);
          Locale.setDefault(originalLocale);
          originalDateTimeZone = null;
          originalTimeZone = null;
          originalLocale = null;
      }
  
      //-----------------------------------------------------------------------
      public void testFactoryUTC() {
          assertEquals(DateTimeZone.UTC, EthiopicChronology.getInstanceUTC().getZone());
          assertSame(EthiopicChronology.class, EthiopicChronology.getInstanceUTC().getClass());
      }
  
      public void testFactory() {
          assertEquals(LONDON, EthiopicChronology.getInstance().getZone());
          assertSame(EthiopicChronology.class, EthiopicChronology.getInstance().getClass());
      }
  
      public void testFactory_Zone() {
          assertEquals(TOKYO, EthiopicChronology.getInstance(TOKYO).getZone());
          assertEquals(PARIS, EthiopicChronology.getInstance(PARIS).getZone());
          assertEquals(LONDON, EthiopicChronology.getInstance(null).getZone());
          assertSame(EthiopicChronology.class, EthiopicChronology.getInstance(TOKYO).getClass());
      }
  
      //-----------------------------------------------------------------------
      public void testEquality() {
          assertSame(EthiopicChronology.getInstance(TOKYO), EthiopicChronology.getInstance(TOKYO));
          assertSame(EthiopicChronology.getInstance(LONDON), EthiopicChronology.getInstance(LONDON));
          assertSame(EthiopicChronology.getInstance(PARIS), EthiopicChronology.getInstance(PARIS));
          assertSame(EthiopicChronology.getInstanceUTC(), EthiopicChronology.getInstanceUTC());
          assertSame(EthiopicChronology.getInstance(), EthiopicChronology.getInstance(LONDON));
      }
  
      public void testWithUTC() {
          assertSame(EthiopicChronology.getInstanceUTC(), EthiopicChronology.getInstance(LONDON).withUTC());
          assertSame(EthiopicChronology.getInstanceUTC(), EthiopicChronology.getInstance(TOKYO).withUTC());
          assertSame(EthiopicChronology.getInstanceUTC(), EthiopicChronology.getInstanceUTC().withUTC());
          assertSame(EthiopicChronology.getInstanceUTC(), EthiopicChronology.getInstance().withUTC());
      }
  
      public void testWithZone() {
          assertSame(EthiopicChronology.getInstance(TOKYO), EthiopicChronology.getInstance(TOKYO).withZone(TOKYO));
          assertSame(EthiopicChronology.getInstance(LONDON), EthiopicChronology.getInstance(TOKYO).withZone(LONDON));
          assertSame(EthiopicChronology.getInstance(PARIS), EthiopicChronology.getInstance(TOKYO).withZone(PARIS));
          assertSame(EthiopicChronology.getInstance(LONDON), EthiopicChronology.getInstance(TOKYO).withZone(null));
          assertSame(EthiopicChronology.getInstance(PARIS), EthiopicChronology.getInstance().withZone(PARIS));
          assertSame(EthiopicChronology.getInstance(PARIS), EthiopicChronology.getInstanceUTC().withZone(PARIS));
      }
  
      public void testToString() {
          assertEquals("EthiopicChronology[Europe/London]", EthiopicChronology.getInstance(LONDON).toString());
          assertEquals("EthiopicChronology[Asia/Tokyo]", EthiopicChronology.getInstance(TOKYO).toString());
          assertEquals("EthiopicChronology[Europe/London]", EthiopicChronology.getInstance().toString());
          assertEquals("EthiopicChronology[UTC]", EthiopicChronology.getInstanceUTC().toString());
      }
  
      //-----------------------------------------------------------------------
      public void testDurationFields() {
          final EthiopicChronology ethiopic = EthiopicChronology.getInstance();
          assertEquals("eras", ethiopic.eras().getName());
          assertEquals("centuries", ethiopic.centuries().getName());
          assertEquals("years", ethiopic.years().getName());
          assertEquals("weekyears", ethiopic.weekyears().getName());
          assertEquals("months", ethiopic.months().getName());
          assertEquals("weeks", ethiopic.weeks().getName());
          assertEquals("days", ethiopic.days().getName());
          assertEquals("halfdays", ethiopic.halfdays().getName());
          assertEquals("hours", ethiopic.hours().getName());
          assertEquals("minutes", ethiopic.minutes().getName());
          assertEquals("seconds", ethiopic.seconds().getName());
          assertEquals("millis", ethiopic.millis().getName());
          
          assertEquals(false, ethiopic.eras().isSupported());
          assertEquals(true, ethiopic.centuries().isSupported());
          assertEquals(true, ethiopic.years().isSupported());
          assertEquals(true, ethiopic.weekyears().isSupported());
          assertEquals(true, ethiopic.months().isSupported());
          assertEquals(true, ethiopic.weeks().isSupported());
          assertEquals(true, ethiopic.days().isSupported());
          assertEquals(true, ethiopic.halfdays().isSupported());
          assertEquals(true, ethiopic.hours().isSupported());
          assertEquals(true, ethiopic.minutes().isSupported());
          assertEquals(true, ethiopic.seconds().isSupported());
          assertEquals(true, ethiopic.millis().isSupported());
          
          assertEquals(false, ethiopic.centuries().isPrecise());
          assertEquals(false, ethiopic.years().isPrecise());
          assertEquals(false, ethiopic.weekyears().isPrecise());
          assertEquals(false, ethiopic.months().isPrecise());
          assertEquals(false, ethiopic.weeks().isPrecise());
          assertEquals(false, ethiopic.days().isPrecise());
          assertEquals(false, ethiopic.halfdays().isPrecise());
          assertEquals(true, ethiopic.hours().isPrecise());
          assertEquals(true, ethiopic.minutes().isPrecise());
          assertEquals(true, ethiopic.seconds().isPrecise());
          assertEquals(true, ethiopic.millis().isPrecise());
          
          final EthiopicChronology ethiopicUTC = EthiopicChronology.getInstanceUTC();
          assertEquals(false, ethiopicUTC.centuries().isPrecise());
          assertEquals(false, ethiopicUTC.years().isPrecise());
          assertEquals(false, ethiopicUTC.weekyears().isPrecise());
          assertEquals(false, ethiopicUTC.months().isPrecise());
          assertEquals(true, ethiopicUTC.weeks().isPrecise());
          assertEquals(true, ethiopicUTC.days().isPrecise());
          assertEquals(true, ethiopicUTC.halfdays().isPrecise());
          assertEquals(true, ethiopicUTC.hours().isPrecise());
          assertEquals(true, ethiopicUTC.minutes().isPrecise());
          assertEquals(true, ethiopicUTC.seconds().isPrecise());
          assertEquals(true, ethiopicUTC.millis().isPrecise());
          
          final DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
          final EthiopicChronology ethiopicGMT = EthiopicChronology.getInstance(gmt);
          assertEquals(false, ethiopicGMT.centuries().isPrecise());
          assertEquals(false, ethiopicGMT.years().isPrecise());
          assertEquals(false, ethiopicGMT.weekyears().isPrecise());
          assertEquals(false, ethiopicGMT.months().isPrecise());
          assertEquals(true, ethiopicGMT.weeks().isPrecise());
          assertEquals(true, ethiopicGMT.days().isPrecise());
          assertEquals(true, ethiopicGMT.halfdays().isPrecise());
          assertEquals(true, ethiopicGMT.hours().isPrecise());
          assertEquals(true, ethiopicGMT.minutes().isPrecise());
          assertEquals(true, ethiopicGMT.seconds().isPrecise());
          assertEquals(true, ethiopicGMT.millis().isPrecise());
      }
  
      public void testDateFields() {
          final EthiopicChronology ethiopic = EthiopicChronology.getInstance();
          assertEquals("era", ethiopic.era().getName());
          assertEquals("centuryOfEra", ethiopic.centuryOfEra().getName());
          assertEquals("yearOfCentury", ethiopic.yearOfCentury().getName());
          assertEquals("yearOfEra", ethiopic.yearOfEra().getName());
          assertEquals("year", ethiopic.year().getName());
          assertEquals("monthOfYear", ethiopic.monthOfYear().getName());
          assertEquals("weekyearOfCentury", ethiopic.weekyearOfCentury().getName());
          assertEquals("weekyear", ethiopic.weekyear().getName());
          assertEquals("weekOfWeekyear", ethiopic.weekOfWeekyear().getName());
          assertEquals("dayOfYear", ethiopic.dayOfYear().getName());
          assertEquals("dayOfMonth", ethiopic.dayOfMonth().getName());
          assertEquals("dayOfWeek", ethiopic.dayOfWeek().getName());
          
          assertEquals(true, ethiopic.era().isSupported());
          assertEquals(true, ethiopic.centuryOfEra().isSupported());
          assertEquals(true, ethiopic.yearOfCentury().isSupported());
          assertEquals(true, ethiopic.yearOfEra().isSupported());
          assertEquals(true, ethiopic.year().isSupported());
          assertEquals(true, ethiopic.monthOfYear().isSupported());
          assertEquals(true, ethiopic.weekyearOfCentury().isSupported());
          assertEquals(true, ethiopic.weekyear().isSupported());
          assertEquals(true, ethiopic.weekOfWeekyear().isSupported());
          assertEquals(true, ethiopic.dayOfYear().isSupported());
          assertEquals(true, ethiopic.dayOfMonth().isSupported());
          assertEquals(true, ethiopic.dayOfWeek().isSupported());
          
          assertEquals(ethiopic.eras(), ethiopic.era().getDurationField());
          assertEquals(ethiopic.centuries(), ethiopic.centuryOfEra().getDurationField());
          assertEquals(ethiopic.years(), ethiopic.yearOfCentury().getDurationField());
          assertEquals(ethiopic.years(), ethiopic.yearOfEra().getDurationField());
          assertEquals(ethiopic.years(), ethiopic.year().getDurationField());
          assertEquals(ethiopic.months(), ethiopic.monthOfYear().getDurationField());
          assertEquals(ethiopic.weekyears(), ethiopic.weekyearOfCentury().getDurationField());
          assertEquals(ethiopic.weekyears(), ethiopic.weekyear().getDurationField());
          assertEquals(ethiopic.weeks(), ethiopic.weekOfWeekyear().getDurationField());
          assertEquals(ethiopic.days(), ethiopic.dayOfYear().getDurationField());
          assertEquals(ethiopic.days(), ethiopic.dayOfMonth().getDurationField());
          assertEquals(ethiopic.days(), ethiopic.dayOfWeek().getDurationField());
          
          assertEquals(null, ethiopic.era().getRangeDurationField());
          assertEquals(ethiopic.eras(), ethiopic.centuryOfEra().getRangeDurationField());
          assertEquals(ethiopic.centuries(), ethiopic.yearOfCentury().getRangeDurationField());
          assertEquals(ethiopic.eras(), ethiopic.yearOfEra().getRangeDurationField());
          assertEquals(null, ethiopic.year().getRangeDurationField());
          assertEquals(ethiopic.years(), ethiopic.monthOfYear().getRangeDurationField());
          assertEquals(ethiopic.centuries(), ethiopic.weekyearOfCentury().getRangeDurationField());
          assertEquals(null, ethiopic.weekyear().getRangeDurationField());
          assertEquals(ethiopic.weekyears(), ethiopic.weekOfWeekyear().getRangeDurationField());
          assertEquals(ethiopic.years(), ethiopic.dayOfYear().getRangeDurationField());
          assertEquals(ethiopic.months(), ethiopic.dayOfMonth().getRangeDurationField());
          assertEquals(ethiopic.weeks(), ethiopic.dayOfWeek().getRangeDurationField());
      }
  
      public void testTimeFields() {
          final EthiopicChronology ethiopic = EthiopicChronology.getInstance();
          assertEquals("halfdayOfDay", ethiopic.halfdayOfDay().getName());
          assertEquals("clockhourOfHalfday", ethiopic.clockhourOfHalfday().getName());
          assertEquals("hourOfHalfday", ethiopic.hourOfHalfday().getName());
          assertEquals("clockhourOfDay", ethiopic.clockhourOfDay().getName());
          assertEquals("hourOfDay", ethiopic.hourOfDay().getName());
          assertEquals("minuteOfDay", ethiopic.minuteOfDay().getName());
          assertEquals("minuteOfHour", ethiopic.minuteOfHour().getName());
          assertEquals("secondOfDay", ethiopic.secondOfDay().getName());
          assertEquals("secondOfMinute", ethiopic.secondOfMinute().getName());
          assertEquals("millisOfDay", ethiopic.millisOfDay().getName());
          assertEquals("millisOfSecond", ethiopic.millisOfSecond().getName());
          
          assertEquals(true, ethiopic.halfdayOfDay().isSupported());
          assertEquals(true, ethiopic.clockhourOfHalfday().isSupported());
          assertEquals(true, ethiopic.hourOfHalfday().isSupported());
          assertEquals(true, ethiopic.clockhourOfDay().isSupported());
          assertEquals(true, ethiopic.hourOfDay().isSupported());
          assertEquals(true, ethiopic.minuteOfDay().isSupported());
          assertEquals(true, ethiopic.minuteOfHour().isSupported());
          assertEquals(true, ethiopic.secondOfDay().isSupported());
          assertEquals(true, ethiopic.secondOfMinute().isSupported());
          assertEquals(true, ethiopic.millisOfDay().isSupported());
          assertEquals(true, ethiopic.millisOfSecond().isSupported());
      }
  
      //-----------------------------------------------------------------------
      public void testEpoch() {
          DateTime epoch = new DateTime(1, 1, 1, 0, 0, 0, 0, ETHIOPIC_UTC);
          assertEquals(new DateTime(8, 8, 29, 0, 0, 0, 0, JULIAN_UTC), epoch.withChronology(JULIAN_UTC));
      }
  
      public void testEra() {
          assertEquals(1, EthiopicChronology.EE);
          try {
              new DateTime(-1, 13, 5, 0, 0, 0, 0, ETHIOPIC_UTC);
              fail();
          } catch (IllegalArgumentException ex) {}
      }
  
      //-----------------------------------------------------------------------
      /**
       * Tests era, year, monthOfYear, dayOfMonth and dayOfWeek.
       */
      public void testCalendar() {
          if (TestAll.FAST) {
              return;
          }
          System.out.println("\nTestEthiopicChronology.testCalendar");
          DateTime epoch = new DateTime(1, 1, 1, 0, 0, 0, 0, ETHIOPIC_UTC);
          long millis = epoch.getMillis();
          long end = new DateTime(3000, 1, 1, 0, 0, 0, 0, ISO_UTC).getMillis();
          DateTimeField dayOfWeek = ETHIOPIC_UTC.dayOfWeek();
          DateTimeField dayOfYear = ETHIOPIC_UTC.dayOfYear();
          DateTimeField dayOfMonth = ETHIOPIC_UTC.dayOfMonth();
          DateTimeField monthOfYear = ETHIOPIC_UTC.monthOfYear();
          DateTimeField year = ETHIOPIC_UTC.year();
          DateTimeField yearOfEra = ETHIOPIC_UTC.yearOfEra();
          DateTimeField era = ETHIOPIC_UTC.era();
          int expectedDOW = new DateTime(8, 8, 29, 0, 0, 0, 0, JULIAN_UTC).getDayOfWeek();
          int expectedDOY = 1;
          int expectedDay = 1;
          int expectedMonth = 1;
          int expectedYear = 1;
          while (millis < end) {
  