org.joda.time.chrono.JulianChronology Java Examples
The following examples show how to use
org.joda.time.chrono.JulianChronology.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CalendarConverter.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example #2
Source File: TestIllegalFieldValueException.java From astor with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #3
Source File: TestChronology.java From astor with GNU General Public License v2.0 | 6 votes |
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()); }
Example #4
Source File: CalendarConverter.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example #5
Source File: TestIllegalFieldValueException.java From astor with GNU General Public License v2.0 | 6 votes |
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()); } }
Example #6
Source File: TestChronology.java From astor with GNU General Public License v2.0 | 6 votes |
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()); }
Example #7
Source File: JulianCalendar.java From levelup-java-examples with Apache License 2.0 | 5 votes |
@Test public void create_julian_date_instance () { // Battle of Megiddo Chronology chrono = JulianChronology.getInstance(); DateTime dateTime = new DateTime(1457, 5, 9, 0, 0, 0, 0, chrono); assertNotNull(dateTime); }
Example #8
Source File: TestStringConverter.java From astor with GNU General Public License v2.0 | 5 votes |
protected void setUp() throws Exception { zone = DateTimeZone.getDefault(); locale = Locale.getDefault(); DateTimeZone.setDefault(LONDON); Locale.setDefault(Locale.UK); JULIAN = JulianChronology.getInstance(); ISO = ISOChronology.getInstance(); }
Example #9
Source File: TestNullConverter.java From astor with GNU General Public License v2.0 | 5 votes |
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(); }
Example #10
Source File: TestStringConverter.java From astor with GNU General Public License v2.0 | 5 votes |
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()); }
Example #11
Source File: TestReadableDurationConverter.java From astor with GNU General Public License v2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); JULIAN = JulianChronology.getInstance(); ISO = ISOChronology.getInstance(); zone = DateTimeZone.getDefault(); DateTimeZone.setDefault(PARIS); }
Example #12
Source File: TestStringConverter.java From astor with GNU General Public License v2.0 | 5 votes |
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()); }
Example #13
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #14
Source File: MainTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * @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(); } }
Example #15
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #16
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #17
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #18
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #19
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #20
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #21
Source File: TestReadableDurationConverter.java From astor with GNU General Public License v2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); JULIAN = JulianChronology.getInstance(); ISO = ISOChronology.getInstance(); zone = DateTimeZone.getDefault(); DateTimeZone.setDefault(PARIS); }
Example #22
Source File: TestNullConverter.java From astor with GNU General Public License v2.0 | 5 votes |
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(); }
Example #23
Source File: TestStringConverter.java From astor with GNU General Public License v2.0 | 5 votes |
protected void setUp() throws Exception { zone = DateTimeZone.getDefault(); locale = Locale.getDefault(); DateTimeZone.setDefault(LONDON); Locale.setDefault(Locale.UK); JULIAN = JulianChronology.getInstance(); ISO = ISOChronology.getInstance(); }
Example #24
Source File: MainTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * @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(); } }
Example #25
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #26
Source File: TestStringConverter.java From astor with GNU General Public License v2.0 | 5 votes |
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()); }
Example #27
Source File: TestStringConverter.java From astor with GNU General Public License v2.0 | 5 votes |
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()); }
Example #28
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #29
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #30
Source File: TestTimeOfDay_Constructors.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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()); }