// ----------------------------------------------------------------------- public void testDurationFields() { final GJChronology gj = GJChronology.getInstance(); assertEquals("eras", gj.eras().getName()); assertEquals("centuries", gj.centuries().getName()); assertEquals("years", gj.years().getName()); assertEquals("weekyears", gj.weekyears().getName()); assertEquals("months", gj.months().getName()); assertEquals("weeks", gj.weeks().getName()); assertEquals("halfdays", gj.halfdays().getName()); assertEquals("days", gj.days().getName()); assertEquals("hours", gj.hours().getName()); assertEquals("minutes", gj.minutes().getName()); assertEquals("seconds", gj.seconds().getName()); assertEquals("millis", gj.millis().getName()); assertEquals(false, gj.eras().isSupported()); assertEquals(true, gj.centuries().isSupported()); assertEquals(true, gj.years().isSupported()); assertEquals(true, gj.weekyears().isSupported()); assertEquals(true, gj.months().isSupported()); assertEquals(true, gj.weeks().isSupported()); assertEquals(true, gj.days().isSupported()); assertEquals(true, gj.halfdays().isSupported()); assertEquals(true, gj.hours().isSupported()); assertEquals(true, gj.minutes().isSupported()); assertEquals(true, gj.seconds().isSupported()); assertEquals(true, gj.millis().isSupported()); assertEquals(false, gj.centuries().isPrecise()); assertEquals(false, gj.years().isPrecise()); assertEquals(false, gj.weekyears().isPrecise()); assertEquals(false, gj.months().isPrecise()); assertEquals(false, gj.weeks().isPrecise()); assertEquals(false, gj.days().isPrecise()); assertEquals(false, gj.halfdays().isPrecise()); assertEquals(true, gj.hours().isPrecise()); assertEquals(true, gj.minutes().isPrecise()); assertEquals(true, gj.seconds().isPrecise()); assertEquals(true, gj.millis().isPrecise()); final GJChronology gjUTC = GJChronology.getInstanceUTC(); assertEquals(false, gjUTC.centuries().isPrecise()); assertEquals(false, gjUTC.years().isPrecise()); assertEquals(false, gjUTC.weekyears().isPrecise()); assertEquals(false, gjUTC.months().isPrecise()); assertEquals(true, gjUTC.weeks().isPrecise()); assertEquals(true, gjUTC.days().isPrecise()); assertEquals(true, gjUTC.halfdays().isPrecise()); assertEquals(true, gjUTC.hours().isPrecise()); assertEquals(true, gjUTC.minutes().isPrecise()); assertEquals(true, gjUTC.seconds().isPrecise()); assertEquals(true, gjUTC.millis().isPrecise()); final DateTimeZone gmt = DateTimeZone.forID("Etc/GMT"); final GJChronology gjGMT = GJChronology.getInstance(gmt); assertEquals(false, gjGMT.centuries().isPrecise()); assertEquals(false, gjGMT.years().isPrecise()); assertEquals(false, gjGMT.weekyears().isPrecise()); assertEquals(false, gjGMT.months().isPrecise()); assertEquals(true, gjGMT.weeks().isPrecise()); assertEquals(true, gjGMT.days().isPrecise()); assertEquals(true, gjGMT.halfdays().isPrecise()); assertEquals(true, gjGMT.hours().isPrecise()); assertEquals(true, gjGMT.minutes().isPrecise()); assertEquals(true, gjGMT.seconds().isPrecise()); assertEquals(true, gjGMT.millis().isPrecise()); }
// ----------------------------------------------------------------------- public void testEquality() { assertSame(GJChronology.getInstance(TOKYO), GJChronology.getInstance(TOKYO)); assertSame(GJChronology.getInstance(LONDON), GJChronology.getInstance(LONDON)); assertSame(GJChronology.getInstance(PARIS), GJChronology.getInstance(PARIS)); assertSame(GJChronology.getInstanceUTC(), GJChronology.getInstanceUTC()); assertSame(GJChronology.getInstance(), GJChronology.getInstance(LONDON)); }
public void testLeapYearRulesConstruction() { // 1500 not leap in Gregorian, but is leap in Julian DateMidnight dt = new DateMidnight(1500, 2, 29, GJChronology.getInstanceUTC()); assertEquals(dt.getYear(), 1500); assertEquals(dt.getMonthOfYear(), 2); assertEquals(dt.getDayOfMonth(), 29); }
public void testWithZone() { assertSame(GJChronology.getInstance(TOKYO), GJChronology.getInstance(TOKYO).withZone(TOKYO)); assertSame(GJChronology.getInstance(LONDON), GJChronology.getInstance(TOKYO).withZone(LONDON)); assertSame(GJChronology.getInstance(PARIS), GJChronology.getInstance(TOKYO).withZone(PARIS)); assertSame(GJChronology.getInstance(LONDON), GJChronology.getInstance(TOKYO).withZone(null)); assertSame(GJChronology.getInstance(PARIS), GJChronology.getInstance().withZone(PARIS)); assertSame(GJChronology.getInstance(PARIS), GJChronology.getInstanceUTC().withZone(PARIS)); }
public void testLeapYearRulesConstructionInvalid() { // 1500 not leap in Gregorian, but is leap in Julian try { new DateMidnight(1500, 2, 30, GJChronology.getInstanceUTC()); fail(); } catch (IllegalFieldValueException ex) { // good } }
public void testToString() { assertEquals("GJChronology[Europe/London]", GJChronology.getInstance(LONDON).toString()); assertEquals("GJChronology[Asia/Tokyo]", GJChronology.getInstance(TOKYO).toString()); assertEquals("GJChronology[Europe/London]", GJChronology.getInstance().toString()); assertEquals("GJChronology[UTC]", GJChronology.getInstanceUTC().toString()); assertEquals( "GJChronology[UTC,cutover=1970-01-01]", GJChronology.getInstance(DateTimeZone.UTC, 0L, 4).toString()); assertEquals( "GJChronology[UTC,cutover=1970-01-01T00:00:00.001Z,mdfw=2]", GJChronology.getInstance(DateTimeZone.UTC, 1L, 2).toString()); }
// ----------------------------------------------------------------------- public void testFactoryUTC() { assertEquals(DateTimeZone.UTC, GJChronology.getInstanceUTC().getZone()); assertSame(GJChronology.class, GJChronology.getInstanceUTC().getClass()); }
public void testWithUTC() { assertSame(GJChronology.getInstanceUTC(), GJChronology.getInstance(LONDON).withUTC()); assertSame(GJChronology.getInstanceUTC(), GJChronology.getInstance(TOKYO).withUTC()); assertSame(GJChronology.getInstanceUTC(), GJChronology.getInstanceUTC().withUTC()); assertSame(GJChronology.getInstanceUTC(), GJChronology.getInstance().withUTC()); }