Java 类org.joda.time.chrono.JulianChronology 实例源码

项目:TinyTravelTracker    文件:CalendarConverter.java   
/**
 * Gets the chronology, which is the GJChronology if a GregorianCalendar is used,
 * BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
 * The time zone specified is used in preference to that on the calendar.
 * 
 * @param object  the Calendar to convert, must not be null
 * @param zone  the specified zone to use, null means default zone
 * @return the chronology, never null
 * @throws NullPointerException if the object is null
 * @throws ClassCastException if the object is an invalid type
 */
public Chronology getChronology(Object object, DateTimeZone zone) {
    if (object.getClass().getName().endsWith(".BuddhistCalendar")) {
        return BuddhistChronology.getInstance(zone);
    } else if (object instanceof GregorianCalendar) {
        GregorianCalendar gc = (GregorianCalendar) object;
        long cutover = gc.getGregorianChange().getTime();
        if (cutover == Long.MIN_VALUE) {
            return GregorianChronology.getInstance(zone);
        } else if (cutover == Long.MAX_VALUE) {
            return JulianChronology.getInstance(zone);
        } else {
            return GJChronology.getInstance(zone, cutover, 4);
        }
    } else {
        return ISOChronology.getInstance(zone);
    }
}
项目:astor    文件:CalendarConverter.java   
/**
 * Gets the chronology, which is the GJChronology if a GregorianCalendar is used,
 * BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
 * The time zone specified is used in preference to that on the calendar.
 * 
 * @param object  the Calendar to convert, must not be null
 * @param zone  the specified zone to use, null means default zone
 * @return the chronology, never null
 * @throws NullPointerException if the object is null
 * @throws ClassCastException if the object is an invalid type
 */
public Chronology getChronology(Object object, DateTimeZone zone) {
    if (object.getClass().getName().endsWith(".BuddhistCalendar")) {
        return BuddhistChronology.getInstance(zone);
    } else if (object instanceof GregorianCalendar) {
        GregorianCalendar gc = (GregorianCalendar) object;
        long cutover = gc.getGregorianChange().getTime();
        if (cutover == Long.MIN_VALUE) {
            return GregorianChronology.getInstance(zone);
        } else if (cutover == Long.MAX_VALUE) {
            return JulianChronology.getInstance(zone);
        } else {
            return GJChronology.getInstance(zone, cutover, 4);
        }
    } else {
        return ISOChronology.getInstance(zone);
    }
}
项目:astor    文件:TestChronology.java   
public void testToString() {
    DateTimeZone paris = DateTimeZone.forID("Europe/Paris");
    ISOChronology isoParis = ISOChronology.getInstance(paris);

    assertEquals("ISOChronology[Europe/Paris]", isoParis.toString());
    assertEquals("GJChronology[Europe/Paris]", GJChronology.getInstance(paris).toString());
    assertEquals("GregorianChronology[Europe/Paris]", GregorianChronology.getInstance(paris).toString());
    assertEquals("JulianChronology[Europe/Paris]", JulianChronology.getInstance(paris).toString());
    assertEquals("BuddhistChronology[Europe/Paris]", BuddhistChronology.getInstance(paris).toString());
    assertEquals("CopticChronology[Europe/Paris]", CopticChronology.getInstance(paris).toString());
    assertEquals("EthiopicChronology[Europe/Paris]", EthiopicChronology.getInstance(paris).toString());
    assertEquals("IslamicChronology[Europe/Paris]", IslamicChronology.getInstance(paris).toString());

    assertEquals("LenientChronology[ISOChronology[Europe/Paris]]", LenientChronology.getInstance(isoParis).toString());
    assertEquals("StrictChronology[ISOChronology[Europe/Paris]]", StrictChronology.getInstance(isoParis).toString());
    assertEquals("LimitChronology[ISOChronology[Europe/Paris], NoLimit, NoLimit]", LimitChronology.getInstance(isoParis, null, null).toString());
    assertEquals("ZonedChronology[ISOChronology[UTC], Europe/Paris]", ZonedChronology.getInstance(isoParis, paris).toString());
}
项目:astor    文件:TestIllegalFieldValueException.java   
public void testJulianYearZero() {
    DateTime dt = new DateTime(JulianChronology.getInstanceUTC());
    try {
        dt.year().setCopy(0);
        fail();
    } catch (IllegalFieldValueException e) {
        assertEquals(DateTimeFieldType.year(), e.getDateTimeFieldType());
        assertEquals(null, e.getDurationFieldType());
        assertEquals("year", e.getFieldName());
        assertEquals(new Integer(0), e.getIllegalNumberValue());
        assertEquals(null, e.getIllegalStringValue());
        assertEquals("0", e.getIllegalValueAsString());
        assertEquals(null, e.getLowerBound());
        assertEquals(null, e.getUpperBound());
    }
}
项目:astor    文件:CalendarConverter.java   
/**
 * Gets the chronology, which is the GJChronology if a GregorianCalendar is used,
 * BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
 * The time zone specified is used in preference to that on the calendar.
 * 
 * @param object  the Calendar to convert, must not be null
 * @param zone  the specified zone to use, null means default zone
 * @return the chronology, never null
 * @throws NullPointerException if the object is null
 * @throws ClassCastException if the object is an invalid type
 */
public Chronology getChronology(Object object, DateTimeZone zone) {
    if (object.getClass().getName().endsWith(".BuddhistCalendar")) {
        return BuddhistChronology.getInstance(zone);
    } else if (object instanceof GregorianCalendar) {
        GregorianCalendar gc = (GregorianCalendar) object;
        long cutover = gc.getGregorianChange().getTime();
        if (cutover == Long.MIN_VALUE) {
            return GregorianChronology.getInstance(zone);
        } else if (cutover == Long.MAX_VALUE) {
            return JulianChronology.getInstance(zone);
        } else {
            return GJChronology.getInstance(zone, cutover, 4);
        }
    } else {
        return ISOChronology.getInstance(zone);
    }
}
项目:astor    文件:TestChronology.java   
public void testToString() {
    DateTimeZone paris = DateTimeZone.forID("Europe/Paris");
    ISOChronology isoParis = ISOChronology.getInstance(paris);

    assertEquals("ISOChronology[Europe/Paris]", isoParis.toString());
    assertEquals("GJChronology[Europe/Paris]", GJChronology.getInstance(paris).toString());
    assertEquals("GregorianChronology[Europe/Paris]", GregorianChronology.getInstance(paris).toString());
    assertEquals("JulianChronology[Europe/Paris]", JulianChronology.getInstance(paris).toString());
    assertEquals("BuddhistChronology[Europe/Paris]", BuddhistChronology.getInstance(paris).toString());
    assertEquals("CopticChronology[Europe/Paris]", CopticChronology.getInstance(paris).toString());
    assertEquals("EthiopicChronology[Europe/Paris]", EthiopicChronology.getInstance(paris).toString());
    assertEquals("IslamicChronology[Europe/Paris]", IslamicChronology.getInstance(paris).toString());

    assertEquals("LenientChronology[ISOChronology[Europe/Paris]]", LenientChronology.getInstance(isoParis).toString());
    assertEquals("StrictChronology[ISOChronology[Europe/Paris]]", StrictChronology.getInstance(isoParis).toString());
    assertEquals("LimitChronology[ISOChronology[Europe/Paris], NoLimit, NoLimit]", LimitChronology.getInstance(isoParis, null, null).toString());
    assertEquals("ZonedChronology[ISOChronology[UTC], Europe/Paris]", ZonedChronology.getInstance(isoParis, paris).toString());
}
项目:astor    文件:TestIllegalFieldValueException.java   
public void testJulianYearZero() {
    DateTime dt = new DateTime(JulianChronology.getInstanceUTC());
    try {
        dt.year().setCopy(0);
        fail();
    } catch (IllegalFieldValueException e) {
        assertEquals(DateTimeFieldType.year(), e.getDateTimeFieldType());
        assertEquals(null, e.getDurationFieldType());
        assertEquals("year", e.getFieldName());
        assertEquals(new Integer(0), e.getIllegalNumberValue());
        assertEquals(null, e.getIllegalStringValue());
        assertEquals("0", e.getIllegalValueAsString());
        assertEquals(null, e.getLowerBound());
        assertEquals(null, e.getUpperBound());
    }
}
项目:edal-java    文件:CdmUtils.java   
private static Chronology getChronologyForString(String chronologyString) {
    if (chronologyString == null || "gregorian".equalsIgnoreCase(chronologyString)
            || "standard".equalsIgnoreCase(chronologyString)) {
        return ISOChronology.getInstanceUTC();
    } else if ("proleptic_gregorian".equalsIgnoreCase(chronologyString)) {
        return GregorianChronology.getInstanceUTC();
    } else if ("julian".equalsIgnoreCase(chronologyString)) {
        return JulianChronology.getInstanceUTC();
    } else if ("noleap".equalsIgnoreCase(chronologyString)
            || "365_day".equalsIgnoreCase(chronologyString)) {
        return NoLeapChronology.getInstanceUTC();
    } else if ("all_leap".equalsIgnoreCase(chronologyString)
            || "366_day".equalsIgnoreCase(chronologyString)) {
        return AllLeapChronology.getInstanceUTC();
    } else if ("360_day".equalsIgnoreCase(chronologyString)) {
        return ThreeSixtyDayChronology.getInstanceUTC();
    }
    return null;
}
项目:idylfin    文件:CalendarConverter.java   
/**
 * Gets the chronology, which is the GJChronology if a GregorianCalendar is used,
 * BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
 * The time zone specified is used in preference to that on the calendar.
 * 
 * @param object  the Calendar to convert, must not be null
 * @param zone  the specified zone to use, null means default zone
 * @return the chronology, never null
 * @throws NullPointerException if the object is null
 * @throws ClassCastException if the object is an invalid type
 */
public Chronology getChronology(Object object, DateTimeZone zone) {
    if (object.getClass().getName().endsWith(".BuddhistCalendar")) {
        return BuddhistChronology.getInstance(zone);
    } else if (object instanceof GregorianCalendar) {
        GregorianCalendar gc = (GregorianCalendar) object;
        long cutover = gc.getGregorianChange().getTime();
        if (cutover == Long.MIN_VALUE) {
            return GregorianChronology.getInstance(zone);
        } else if (cutover == Long.MAX_VALUE) {
            return JulianChronology.getInstance(zone);
        } else {
            return GJChronology.getInstance(zone, cutover, 4);
        }
    } else {
        return ISOChronology.getInstance(zone);
    }
}
项目:versemem-android    文件:CalendarConverter.java   
/**
 * Gets the chronology, which is the GJChronology if a GregorianCalendar is used,
 * BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
 * The time zone specified is used in preference to that on the calendar.
 * 
 * @param object  the Calendar to convert, must not be null
 * @param zone  the specified zone to use, null means default zone
 * @return the chronology, never null
 * @throws NullPointerException if the object is null
 * @throws ClassCastException if the object is an invalid type
 */
public Chronology getChronology(Object object, DateTimeZone zone) {
    if (object.getClass().getName().endsWith(".BuddhistCalendar")) {
        return BuddhistChronology.getInstance(zone);
    } else if (object instanceof GregorianCalendar) {
        GregorianCalendar gc = (GregorianCalendar) object;
        long cutover = gc.getGregorianChange().getTime();
        if (cutover == Long.MIN_VALUE) {
            return GregorianChronology.getInstance(zone);
        } else if (cutover == Long.MAX_VALUE) {
            return JulianChronology.getInstance(zone);
        } else {
            return GJChronology.getInstance(zone, cutover, 4);
        }
    } else {
        return ISOChronology.getInstance(zone);
    }
}
项目:versemem-android    文件:TestChronology.java   
public void testToString() {
    DateTimeZone paris = DateTimeZone.forID("Europe/Paris");
    ISOChronology isoParis = ISOChronology.getInstance(paris);

    assertEquals("ISOChronology[Europe/Paris]", isoParis.toString());
    assertEquals("GJChronology[Europe/Paris]", GJChronology.getInstance(paris).toString());
    assertEquals("GregorianChronology[Europe/Paris]", GregorianChronology.getInstance(paris).toString());
    assertEquals("JulianChronology[Europe/Paris]", JulianChronology.getInstance(paris).toString());
    assertEquals("BuddhistChronology[Europe/Paris]", BuddhistChronology.getInstance(paris).toString());
    assertEquals("CopticChronology[Europe/Paris]", CopticChronology.getInstance(paris).toString());
    assertEquals("EthiopicChronology[Europe/Paris]", EthiopicChronology.getInstance(paris).toString());
    assertEquals("IslamicChronology[Europe/Paris]", IslamicChronology.getInstance(paris).toString());

    assertEquals("LenientChronology[ISOChronology[Europe/Paris]]", LenientChronology.getInstance(isoParis).toString());
    assertEquals("StrictChronology[ISOChronology[Europe/Paris]]", StrictChronology.getInstance(isoParis).toString());
    assertEquals("LimitChronology[ISOChronology[Europe/Paris], NoLimit, NoLimit]", LimitChronology.getInstance(isoParis, null, null).toString());
    assertEquals("ZonedChronology[ISOChronology[UTC], Europe/Paris]", ZonedChronology.getInstance(isoParis, paris).toString());
}
项目:versemem-android    文件:TestIllegalFieldValueException.java   
public void testJulianYearZero() {
    DateTime dt = new DateTime(JulianChronology.getInstanceUTC());
    try {
        dt.year().setCopy(0);
        fail();
    } catch (IllegalFieldValueException e) {
        assertEquals(DateTimeFieldType.year(), e.getDateTimeFieldType());
        assertEquals(null, e.getDurationFieldType());
        assertEquals("year", e.getFieldName());
        assertEquals(new Integer(0), e.getIllegalNumberValue());
        assertEquals(null, e.getIllegalStringValue());
        assertEquals("0", e.getIllegalValueAsString());
        assertEquals(null, e.getLowerBound());
        assertEquals(null, e.getUpperBound());
    }
}
项目:astor    文件:TestCalendarConverter.java   
public void testGetChronology_Object_Zone() throws Exception {
    GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
    assertEquals(GJChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(cal, MOSCOW));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    assertEquals(GJChronology.getInstance(), CalendarConverter.INSTANCE.getChronology(cal, (DateTimeZone) null));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(0L));
    assertEquals(GJChronology.getInstance(MOSCOW, 0L, 4), CalendarConverter.INSTANCE.getChronology(cal, MOSCOW));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(Long.MAX_VALUE));
    assertEquals(JulianChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(cal, PARIS));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    assertEquals(GregorianChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(cal, PARIS));

    Calendar uc = new MockUnknownCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    assertEquals(ISOChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(uc, PARIS));

    try {
        Calendar bc = (Calendar) Class.forName("sun.util.BuddhistCalendar").newInstance();
        bc.setTimeZone(TimeZone.getTimeZone("Europe/Moscow"));
        assertEquals(BuddhistChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(bc, PARIS));
    } catch (ClassNotFoundException ex) {
        // ignore
    }
}
项目:astor    文件:TestCalendarConverter.java   
public void testGetChronology_Object_nullChronology() throws Exception {
    GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
    assertEquals(GJChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(0L));
    assertEquals(GJChronology.getInstance(MOSCOW, 0L, 4), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(Long.MAX_VALUE));
    assertEquals(JulianChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    assertEquals(GregorianChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    cal = new GregorianCalendar(new MockUnknownTimeZone());
    assertEquals(GJChronology.getInstance(), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    Calendar uc = new MockUnknownCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    assertEquals(ISOChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(uc, (Chronology) null));

    try {
        Calendar bc = (Calendar) Class.forName("sun.util.BuddhistCalendar").newInstance();
        bc.setTimeZone(TimeZone.getTimeZone("Europe/Moscow"));
        assertEquals(BuddhistChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(bc, (Chronology) null));
    } catch (ClassNotFoundException ex) {
        // ignore
    }
}
项目:astor    文件:TestReadableDurationConverter.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    JULIAN = JulianChronology.getInstance();
    ISO = ISOChronology.getInstance();
    zone = DateTimeZone.getDefault();
    DateTimeZone.setDefault(PARIS);
}
项目:astor    文件:TestNullConverter.java   
protected void setUp() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
    originalDateTimeZone = DateTimeZone.getDefault();
    originalTimeZone = TimeZone.getDefault();
    originalLocale = Locale.getDefault();
    DateTimeZone.setDefault(DateTimeZone.forID("Europe/London"));
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Locale.setDefault(Locale.UK);

    ISO = ISOChronology.getInstance();
    JULIAN = JulianChronology.getInstance();
}
项目:astor    文件:TestStringConverter.java   
protected void setUp() throws Exception {
    zone = DateTimeZone.getDefault();
    locale = Locale.getDefault();
    DateTimeZone.setDefault(LONDON);
    Locale.setDefault(Locale.UK);

    JULIAN = JulianChronology.getInstance();
    ISO = ISOChronology.getInstance();
}
项目:astor    文件:TestStringConverter.java   
public void testGetDateTime5() throws Exception {
    DateTime test = new DateTime("2004-06-09T12:24:48.501+02:00", JulianChronology.getInstance(PARIS));
    assertEquals(2004, test.getYear());
    assertEquals(6, test.getMonthOfYear());
    assertEquals(9, test.getDayOfMonth());
    assertEquals(12, test.getHourOfDay());
    assertEquals(24, test.getMinuteOfHour());
    assertEquals(48, test.getSecondOfMinute());
    assertEquals(501, test.getMillisOfSecond());
    assertEquals(PARIS, test.getZone());
}
项目:astor    文件:TestStringConverter.java   
public void testGetDateTime6() throws Exception {
    DateTime test = new DateTime("2004-06-09T12:24:48.501", JulianChronology.getInstance(PARIS));
    assertEquals(2004, test.getYear());
    assertEquals(6, test.getMonthOfYear());
    assertEquals(9, test.getDayOfMonth());
    assertEquals(12, test.getHourOfDay());
    assertEquals(24, test.getMinuteOfHour());
    assertEquals(48, test.getSecondOfMinute());
    assertEquals(501, test.getMillisOfSecond());
    assertEquals(PARIS, test.getZone());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test factory (long, Chronology)
 */
public void testFactoryMillisOfDay_long1_Chronology() throws Throwable {
    TimeOfDay test = TimeOfDay.fromMillisOfDay(TEST_TIME1, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(1, test.getHourOfDay());
    assertEquals(2, test.getMinuteOfHour());
    assertEquals(3, test.getSecondOfMinute());
    assertEquals(4, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (Chronology)
 */
public void testConstructor_Chronology() throws Throwable {
    TimeOfDay test = new TimeOfDay(JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(10 + OFFSET, test.getHourOfDay());
    assertEquals(20, test.getMinuteOfHour());
    assertEquals(30, test.getSecondOfMinute());
    assertEquals(40, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (long, Chronology)
 */
public void testConstructor_long1_Chronology() throws Throwable {
    TimeOfDay test = new TimeOfDay(TEST_TIME1, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(1 + OFFSET, test.getHourOfDay());
    assertEquals(2, test.getMinuteOfHour());
    assertEquals(3, test.getSecondOfMinute());
    assertEquals(4, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (long, Chronology)
 */
public void testConstructor_long2_Chronology() throws Throwable {
    TimeOfDay test = new TimeOfDay(TEST_TIME2, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(5 + OFFSET, test.getHourOfDay());
    assertEquals(6, test.getMinuteOfHour());
    assertEquals(7, test.getSecondOfMinute());
    assertEquals(8, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (Object, Chronology)
 */
public void testConstructor_Object_Chronology() throws Throwable {
    Date date = new Date(TEST_TIME1);
    TimeOfDay test = new TimeOfDay(date, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(1 + OFFSET, test.getHourOfDay());
    assertEquals(2, test.getMinuteOfHour());
    assertEquals(3, test.getSecondOfMinute());
    assertEquals(4, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (Object=null, Chronology)
 */
public void testConstructor_nullObject_Chronology() throws Throwable {
    TimeOfDay test = new TimeOfDay((Object) null, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(10 + OFFSET, test.getHourOfDay());
    assertEquals(20, test.getMinuteOfHour());
    assertEquals(30, test.getSecondOfMinute());
    assertEquals(40, test.getMillisOfSecond());
}
项目:astor    文件:MainTest.java   
/**
 * @param iterations number of test iterations to perform
 * @param mode GREGORIAN_MODE or JULIAN_MODE,0=Gregorian, 1=Julian
 * @param seed seed for random number generator
 */
public MainTest(int iterations, int mode, long seed) {
    super("testChronology");
    iIterations = iterations;
    iMode = mode;
    iSeed = seed;
    if (mode == GREGORIAN_MODE) {
        iTest = new TestGregorianChronology();
        iActual = GregorianChronology.getInstanceUTC();
    } else {
        iTest = new TestJulianChronology();
        iActual = JulianChronology.getInstanceUTC();
    }
}
项目:astor    文件:TestCalendarConverter.java   
public void testGetChronology_Object_Zone() throws Exception {
    GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
    assertEquals(GJChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(cal, MOSCOW));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    assertEquals(GJChronology.getInstance(), CalendarConverter.INSTANCE.getChronology(cal, (DateTimeZone) null));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(0L));
    assertEquals(GJChronology.getInstance(MOSCOW, 0L, 4), CalendarConverter.INSTANCE.getChronology(cal, MOSCOW));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(Long.MAX_VALUE));
    assertEquals(JulianChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(cal, PARIS));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    assertEquals(GregorianChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(cal, PARIS));

    Calendar uc = new MockUnknownCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    assertEquals(ISOChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(uc, PARIS));

    try {
        Calendar bc = (Calendar) Class.forName("sun.util.BuddhistCalendar").newInstance();
        bc.setTimeZone(TimeZone.getTimeZone("Europe/Moscow"));
        assertEquals(BuddhistChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(bc, PARIS));
    } catch (ClassNotFoundException ex) {
        // ignore
    }
}
项目:astor    文件:TestCalendarConverter.java   
public void testGetChronology_Object_nullChronology() throws Exception {
    GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
    assertEquals(GJChronology.getInstance(PARIS), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(0L));
    assertEquals(GJChronology.getInstance(MOSCOW, 0L, 4), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(Long.MAX_VALUE));
    assertEquals(JulianChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    assertEquals(GregorianChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    cal = new GregorianCalendar(new MockUnknownTimeZone());
    assertEquals(GJChronology.getInstance(), CalendarConverter.INSTANCE.getChronology(cal, (Chronology) null));

    Calendar uc = new MockUnknownCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    assertEquals(ISOChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(uc, (Chronology) null));

    try {
        Calendar bc = (Calendar) Class.forName("sun.util.BuddhistCalendar").newInstance();
        bc.setTimeZone(TimeZone.getTimeZone("Europe/Moscow"));
        assertEquals(BuddhistChronology.getInstance(MOSCOW), CalendarConverter.INSTANCE.getChronology(bc, (Chronology) null));
    } catch (ClassNotFoundException ex) {
        // ignore
    }
}
项目:astor    文件:TestReadableDurationConverter.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    JULIAN = JulianChronology.getInstance();
    ISO = ISOChronology.getInstance();
    zone = DateTimeZone.getDefault();
    DateTimeZone.setDefault(PARIS);
}
项目:astor    文件:TestNullConverter.java   
protected void setUp() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
    originalDateTimeZone = DateTimeZone.getDefault();
    originalTimeZone = TimeZone.getDefault();
    originalLocale = Locale.getDefault();
    DateTimeZone.setDefault(DateTimeZone.forID("Europe/London"));
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
    Locale.setDefault(Locale.UK);

    ISO = ISOChronology.getInstance();
    JULIAN = JulianChronology.getInstance();
}
项目:astor    文件:TestStringConverter.java   
protected void setUp() throws Exception {
    zone = DateTimeZone.getDefault();
    locale = Locale.getDefault();
    DateTimeZone.setDefault(LONDON);
    Locale.setDefault(Locale.UK);

    JULIAN = JulianChronology.getInstance();
    ISO = ISOChronology.getInstance();
}
项目:astor    文件:TestStringConverter.java   
public void testGetDateTime5() throws Exception {
    DateTime test = new DateTime("2004-06-09T12:24:48.501+02:00", JulianChronology.getInstance(PARIS));
    assertEquals(2004, test.getYear());
    assertEquals(6, test.getMonthOfYear());
    assertEquals(9, test.getDayOfMonth());
    assertEquals(12, test.getHourOfDay());
    assertEquals(24, test.getMinuteOfHour());
    assertEquals(48, test.getSecondOfMinute());
    assertEquals(501, test.getMillisOfSecond());
    assertEquals(PARIS, test.getZone());
}
项目:astor    文件:TestStringConverter.java   
public void testGetDateTime6() throws Exception {
    DateTime test = new DateTime("2004-06-09T12:24:48.501", JulianChronology.getInstance(PARIS));
    assertEquals(2004, test.getYear());
    assertEquals(6, test.getMonthOfYear());
    assertEquals(9, test.getDayOfMonth());
    assertEquals(12, test.getHourOfDay());
    assertEquals(24, test.getMinuteOfHour());
    assertEquals(48, test.getSecondOfMinute());
    assertEquals(501, test.getMillisOfSecond());
    assertEquals(PARIS, test.getZone());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test factory (long, Chronology)
 */
public void testFactoryMillisOfDay_long1_Chronology() throws Throwable {
    TimeOfDay test = TimeOfDay.fromMillisOfDay(TEST_TIME1, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(1, test.getHourOfDay());
    assertEquals(2, test.getMinuteOfHour());
    assertEquals(3, test.getSecondOfMinute());
    assertEquals(4, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (Chronology)
 */
public void testConstructor_Chronology() throws Throwable {
    TimeOfDay test = new TimeOfDay(JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(10 + OFFSET, test.getHourOfDay());
    assertEquals(20, test.getMinuteOfHour());
    assertEquals(30, test.getSecondOfMinute());
    assertEquals(40, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (long, Chronology)
 */
public void testConstructor_long1_Chronology() throws Throwable {
    TimeOfDay test = new TimeOfDay(TEST_TIME1, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(1 + OFFSET, test.getHourOfDay());
    assertEquals(2, test.getMinuteOfHour());
    assertEquals(3, test.getSecondOfMinute());
    assertEquals(4, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (long, Chronology)
 */
public void testConstructor_long2_Chronology() throws Throwable {
    TimeOfDay test = new TimeOfDay(TEST_TIME2, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(5 + OFFSET, test.getHourOfDay());
    assertEquals(6, test.getMinuteOfHour());
    assertEquals(7, test.getSecondOfMinute());
    assertEquals(8, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (Object, Chronology)
 */
public void testConstructor_Object_Chronology() throws Throwable {
    Date date = new Date(TEST_TIME1);
    TimeOfDay test = new TimeOfDay(date, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(1 + OFFSET, test.getHourOfDay());
    assertEquals(2, test.getMinuteOfHour());
    assertEquals(3, test.getSecondOfMinute());
    assertEquals(4, test.getMillisOfSecond());
}
项目:astor    文件:TestTimeOfDay_Constructors.java   
/**
 * Test constructor (Object=null, Chronology)
 */
public void testConstructor_nullObject_Chronology() throws Throwable {
    TimeOfDay test = new TimeOfDay((Object) null, JulianChronology.getInstance());
    assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
    assertEquals(10 + OFFSET, test.getHourOfDay());
    assertEquals(20, test.getMinuteOfHour());
    assertEquals(30, test.getSecondOfMinute());
    assertEquals(40, test.getMillisOfSecond());
}
项目:astor    文件:MainTest.java   
/**
 * @param iterations number of test iterations to perform
 * @param mode GREGORIAN_MODE or JULIAN_MODE,0=Gregorian, 1=Julian
 * @param seed seed for random number generator
 */
public MainTest(int iterations, int mode, long seed) {
    super("testChronology");
    iIterations = iterations;
    iMode = mode;
    iSeed = seed;
    if (mode == GREGORIAN_MODE) {
        iTest = new TestGregorianChronology();
        iActual = GregorianChronology.getInstanceUTC();
    } else {
        iTest = new TestJulianChronology();
        iActual = JulianChronology.getInstanceUTC();
    }
}