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

下面列出了怎么用org.joda.time.chrono.JulianChronology的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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);
    }
}
 
源代码2 项目: 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());
}
 
源代码3 项目: 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());
    }
}
 
源代码4 项目: 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);
    }
}
 
源代码5 项目: 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());
}
 
源代码6 项目: 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());
    }
}
 
源代码7 项目: astor   文件: TestReadableDurationConverter.java
@Override
protected void setUp() throws Exception {
    super.setUp();
    JULIAN = JulianChronology.getInstance();
    ISO = ISOChronology.getInstance();
    zone = DateTimeZone.getDefault();
    DateTimeZone.setDefault(PARIS);
}
 
源代码8 项目: 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();
}
 
源代码9 项目: 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();
}
 
源代码10 项目: 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());
}
 
源代码11 项目: 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());
}
 
源代码12 项目: 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());
}
 
源代码13 项目: 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());
}
 
源代码14 项目: 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());
}
 
源代码15 项目: 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());
}
 
源代码16 项目: 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());
}
 
源代码17 项目: 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());
}
 
源代码18 项目: 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();
    }
}
 
源代码19 项目: astor   文件: TestReadableDurationConverter.java
@Override
protected void setUp() throws Exception {
    super.setUp();
    JULIAN = JulianChronology.getInstance();
    ISO = ISOChronology.getInstance();
    zone = DateTimeZone.getDefault();
    DateTimeZone.setDefault(PARIS);
}
 
源代码20 项目: 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();
}
 
源代码21 项目: 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();
}
 
源代码22 项目: 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());
}
 
源代码23 项目: 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());
}
 
源代码24 项目: 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());
}
 
源代码25 项目: 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());
}
 
源代码26 项目: 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());
}
 
源代码27 项目: 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());
}
 
源代码28 项目: 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());
}
 
源代码29 项目: 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());
}
 
源代码30 项目: 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();
    }
}
 
 类所在包
 类方法
 同包方法