本文整理汇总了Java中org.joda.time.chrono.JulianChronology类的典型用法代码示例。如果您正苦于以下问题:Java JulianChronology类的具体用法?Java JulianChronology怎么用?Java JulianChronology使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JulianChronology类属于org.joda.time.chrono包,在下文中一共展示了JulianChronology类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChronology
import org.joda.time.chrono.JulianChronology; //导入依赖的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);
}
}
示例2: testToString
import org.joda.time.chrono.JulianChronology; //导入依赖的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());
}
示例3: testJulianYearZero
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
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: getChronologyForString
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
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;
}
示例5: testGetChronology_Object_Zone
import org.joda.time.chrono.JulianChronology; //导入依赖的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
}
}
示例6: testGetChronology_Object_nullChronology
import org.joda.time.chrono.JulianChronology; //导入依赖的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
}
}
示例7: setUp
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
JULIAN = JulianChronology.getInstance();
ISO = ISOChronology.getInstance();
zone = DateTimeZone.getDefault();
DateTimeZone.setDefault(PARIS);
}
示例8: setUp
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
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: setUp
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
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: testGetDateTime5
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
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: testGetDateTime6
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
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: testFactoryMillisOfDay_long1_Chronology
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
/**
* 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: testConstructor_Chronology
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
/**
* 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: testConstructor_long1_Chronology
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
/**
* 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: testConstructor_long2_Chronology
import org.joda.time.chrono.JulianChronology; //导入依赖的package包/类
/**
* 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());
}