当前位置: 首页>>代码示例>>Java>>正文


Java BuddhistChronology类代码示例

本文整理汇总了Java中org.joda.time.chrono.BuddhistChronology的典型用法代码示例。如果您正苦于以下问题:Java BuddhistChronology类的具体用法?Java BuddhistChronology怎么用?Java BuddhistChronology使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BuddhistChronology类属于org.joda.time.chrono包,在下文中一共展示了BuddhistChronology类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getChronology

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:29,代码来源:CalendarConverter.java

示例2: testToString

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
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());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:TestChronology.java

示例3: testGetInstantChronology_RI

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testGetInstantChronology_RI() {
    DateTime dt = new DateTime(123L, BuddhistChronology.getInstance());
    assertEquals(BuddhistChronology.getInstance(), DateTimeUtils.getInstantChronology(dt));
    
    Instant i = new Instant(123L);
    assertEquals(ISOChronology.getInstanceUTC(), DateTimeUtils.getInstantChronology(i));
    
    AbstractInstant ai = new AbstractInstant() {
        public long getMillis() {
            return 0L;
        }
        public Chronology getChronology() {
            return null; // testing for this
        }
    };
    assertEquals(ISOChronology.getInstance(), DateTimeUtils.getInstantChronology(ai));
    
    assertEquals(ISOChronology.getInstance(), DateTimeUtils.getInstantChronology(null));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:TestDateTimeUtils.java

示例4: testMinusYears_int

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testMinusYears_int() {
    YearMonthDay test = new YearMonthDay(2002, 5, 3, BuddhistChronology.getInstance());
    YearMonthDay result = test.minusYears(1);
    YearMonthDay expected = new YearMonthDay(2001, 5, 3, BuddhistChronology.getInstance());
    assertEquals(expected, result);
    
    result = test.minusYears(0);
    assertSame(test, result);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:TestYearMonthDay_Basics.java

示例5: testConstructor_Object_Chronology1

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testConstructor_Object_Chronology1() throws Throwable {
    DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
    DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
    Interval base = new Interval(dt1, dt2);
    
    Interval test = new Interval(base, BuddhistChronology.getInstance());
    assertEquals(dt1.getMillis(), test.getStartMillis());
    assertEquals(dt2.getMillis(), test.getEndMillis());
    assertEquals(BuddhistChronology.getInstance(), test.getChronology());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:TestInterval_Constructors.java

示例6: testPlusDays_int

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testPlusDays_int() {
    YearMonthDay test = new YearMonthDay(2002, 5, 3, BuddhistChronology.getInstance());
    YearMonthDay result = test.plusDays(1);
    YearMonthDay expected = new YearMonthDay(2002, 5, 4, BuddhistChronology.getInstance());
    assertEquals(expected, result);
    
    result = test.plusDays(0);
    assertSame(test, result);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:TestYearMonthDay_Basics.java

示例7: testPlus_RP

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testPlus_RP() {
    MonthDay test = new MonthDay(6, 5, BuddhistChronology.getInstance());
    MonthDay result = test.plus(new Period(1, 2, 3, 4, 5, 6, 7, 8));
    MonthDay expected = new MonthDay(8, 9, BuddhistChronology.getInstance());
    assertEquals(expected, result);
    
    result = test.plus((ReadablePeriod) null);
    assertSame(test, result);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:TestMonthDay_Basics.java

示例8: testMinus_RP

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testMinus_RP() {
    YearMonthDay test = new YearMonthDay(2002, 5, 3, BuddhistChronology.getInstance());
    YearMonthDay result = test.minus(new Period(1, 1, 1, 1, 1, 1, 1, 1));
    YearMonthDay expected = new YearMonthDay(2001, 4, 2, BuddhistChronology.getInstance());
    assertEquals(expected, result);
    
    result = test.minus((ReadablePeriod) null);
    assertSame(test, result);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:TestYearMonthDay_Basics.java

示例9: testGetChronology_Object_Zone

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
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
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:31,代码来源:TestCalendarConverter.java

示例10: testGetChronology_Object_nullChronology

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
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
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:31,代码来源:TestCalendarConverter.java

示例11: testSetIntoInterval_Object_Chronology7

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testSetIntoInterval_Object_Chronology7() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09/2004-06-09", BuddhistChronology.getInstance());
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0, BuddhistChronology.getInstance()), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, BuddhistChronology.getInstance()), m.getEnd());
    assertEquals(BuddhistChronology.getInstance(), m.getChronology());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:8,代码来源:TestStringConverter.java

示例12: testSetIntoInterval_Object_Chronology8

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testSetIntoInterval_Object_Chronology8() throws Exception {
    MutableInterval m = new MutableInterval(-1000L, 1000L);
    StringConverter.INSTANCE.setInto(m, "2003-08-09T+06:00/2004-06-09T+07:00", BuddhistChronology.getInstance(EIGHT));
    assertEquals(new DateTime(2003, 8, 9, 0, 0, 0, 0, BuddhistChronology.getInstance(SIX)).withZone(EIGHT), m.getStart());
    assertEquals(new DateTime(2004, 6, 9, 0, 0, 0, 0, BuddhistChronology.getInstance(SEVEN)).withZone(EIGHT), m.getEnd());
    assertEquals(BuddhistChronology.getInstance(EIGHT), m.getChronology());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:8,代码来源:TestStringConverter.java

示例13: testSetIntoInterval_Object1

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testSetIntoInterval_Object1() throws Exception {
    Interval i = new Interval(0L, 123L, CopticChronology.getInstance());
    MutableInterval m = new MutableInterval(-1000L, 1000L, BuddhistChronology.getInstance());
    ReadableIntervalConverter.INSTANCE.setInto(m, i, null);
    assertEquals(0L, m.getStartMillis());
    assertEquals(123L, m.getEndMillis());
    assertEquals(CopticChronology.getInstance(), m.getChronology());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:9,代码来源:TestReadableIntervalConverter.java

示例14: testSetIntoInterval_Object2

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testSetIntoInterval_Object2() throws Exception {
    Interval i = new Interval(0L, 123L, CopticChronology.getInstance());
    MutableInterval m = new MutableInterval(-1000L, 1000L, BuddhistChronology.getInstance());
    ReadableIntervalConverter.INSTANCE.setInto(m, i, GJChronology.getInstance());
    assertEquals(0L, m.getStartMillis());
    assertEquals(123L, m.getEndMillis());
    assertEquals(GJChronology.getInstance(), m.getChronology());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:9,代码来源:TestReadableIntervalConverter.java

示例15: testSetIntoInterval_Object3

import org.joda.time.chrono.BuddhistChronology; //导入依赖的package包/类
public void testSetIntoInterval_Object3() throws Exception {
    MutableInterval i = new MutableInterval(0L, 123L) {
        public Chronology getChronology() {
            return null; // bad
        }
    };
    MutableInterval m = new MutableInterval(-1000L, 1000L, BuddhistChronology.getInstance());
    ReadableIntervalConverter.INSTANCE.setInto(m, i, GJChronology.getInstance());
    assertEquals(0L, m.getStartMillis());
    assertEquals(123L, m.getEndMillis());
    assertEquals(GJChronology.getInstance(), m.getChronology());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:13,代码来源:TestReadableIntervalConverter.java


注:本文中的org.joda.time.chrono.BuddhistChronology类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。