Java源码示例:org.joda.time.chrono.GregorianChronology
示例1
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());
}
示例2
public void testIsEqual_MD() {
MonthDay test1 = new MonthDay(6, 6);
MonthDay test1a = new MonthDay(6, 6);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
MonthDay test2 = new MonthDay(6, 7);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
MonthDay test3 = new MonthDay(6, 7, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
try {
new MonthDay(6, 7).isEqual(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例3
public void testIsBefore_MD() {
MonthDay test1 = new MonthDay(6, 6);
MonthDay test1a = new MonthDay(6, 6);
assertEquals(false, test1.isBefore(test1a));
assertEquals(false, test1a.isBefore(test1));
assertEquals(false, test1.isBefore(test1));
assertEquals(false, test1a.isBefore(test1a));
MonthDay test2 = new MonthDay(6, 7);
assertEquals(true, test1.isBefore(test2));
assertEquals(false, test2.isBefore(test1));
MonthDay test3 = new MonthDay(6, 7, GregorianChronology.getInstanceUTC());
assertEquals(true, test1.isBefore(test3));
assertEquals(false, test3.isBefore(test1));
assertEquals(false, test3.isBefore(test2));
try {
new MonthDay(6, 7).isBefore(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例4
public void testIsAfter_MD() {
MonthDay test1 = new MonthDay(6, 6);
MonthDay test1a = new MonthDay(6, 6);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
MonthDay test2 = new MonthDay(6, 7);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
MonthDay test3 = new MonthDay(6, 7, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
try {
new MonthDay(6, 7).isAfter(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例5
public void testIsBefore_LocalTime() {
LocalTime test1 = new LocalTime(10, 20, 30, 40);
LocalTime test1a = new LocalTime(10, 20, 30, 40);
assertEquals(false, test1.isBefore(test1a));
assertEquals(false, test1a.isBefore(test1));
assertEquals(false, test1.isBefore(test1));
assertEquals(false, test1a.isBefore(test1a));
LocalTime test2 = new LocalTime(10, 20, 35, 40);
assertEquals(true, test1.isBefore(test2));
assertEquals(false, test2.isBefore(test1));
LocalTime test3 = new LocalTime(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(true, test1.isBefore(test3));
assertEquals(false, test3.isBefore(test1));
assertEquals(false, test3.isBefore(test2));
try {
new LocalTime(10, 20, 35, 40).isBefore(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例6
public void testIsAfter_TOD() {
TimeOfDay test1 = new TimeOfDay(10, 20, 30, 40);
TimeOfDay test1a = new TimeOfDay(10, 20, 30, 40);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
TimeOfDay test2 = new TimeOfDay(10, 20, 35, 40);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
TimeOfDay test3 = new TimeOfDay(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
try {
new TimeOfDay(10, 20, 35, 40).isAfter(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例7
public void testIsEqual_RI() {
Instant test1 = new Instant(TEST_TIME1);
Instant test1a = new Instant(TEST_TIME1);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
Instant test2 = new Instant(TEST_TIME2);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
DateTime test3 = new DateTime(TEST_TIME2, GregorianChronology.getInstance(PARIS));
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
assertEquals(false, test2.isEqual(new MockInstant()));
assertEquals(true, test1.isEqual(new MockInstant()));
assertEquals(false, new Instant(TEST_TIME_NOW + 1).isEqual(null));
assertEquals(true, new Instant(TEST_TIME_NOW).isEqual(null));
assertEquals(false, new Instant(TEST_TIME_NOW - 1).isEqual(null));
}
示例8
public void testIsBefore_RI() {
Instant test1 = new Instant(TEST_TIME1);
Instant test1a = new Instant(TEST_TIME1);
assertEquals(false, test1.isBefore(test1a));
assertEquals(false, test1a.isBefore(test1));
assertEquals(false, test1.isBefore(test1));
assertEquals(false, test1a.isBefore(test1a));
Instant test2 = new Instant(TEST_TIME2);
assertEquals(true, test1.isBefore(test2));
assertEquals(false, test2.isBefore(test1));
DateTime test3 = new DateTime(TEST_TIME2, GregorianChronology.getInstance(PARIS));
assertEquals(true, test1.isBefore(test3));
assertEquals(false, test3.isBefore(test1));
assertEquals(false, test3.isBefore(test2));
assertEquals(false, test2.isBefore(new MockInstant()));
assertEquals(false, test1.isBefore(new MockInstant()));
assertEquals(false, new Instant(TEST_TIME_NOW + 1).isBefore(null));
assertEquals(false, new Instant(TEST_TIME_NOW).isBefore(null));
assertEquals(true, new Instant(TEST_TIME_NOW - 1).isBefore(null));
}
示例9
public void testIsAfter_RI() {
Instant test1 = new Instant(TEST_TIME1);
Instant test1a = new Instant(TEST_TIME1);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
Instant test2 = new Instant(TEST_TIME2);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
DateTime test3 = new DateTime(TEST_TIME2, GregorianChronology.getInstance(PARIS));
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
assertEquals(true, test2.isAfter(new MockInstant()));
assertEquals(false, test1.isAfter(new MockInstant()));
assertEquals(true, new Instant(TEST_TIME_NOW + 1).isAfter(null));
assertEquals(false, new Instant(TEST_TIME_NOW).isAfter(null));
assertEquals(false, new Instant(TEST_TIME_NOW - 1).isAfter(null));
}
示例10
public void testIsEqual_YM() {
YearMonth test1 = new YearMonth(2005, 6);
YearMonth test1a = new YearMonth(2005, 6);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
YearMonth test2 = new YearMonth(2005, 7);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
YearMonth test3 = new YearMonth(2005, 7, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
try {
new YearMonth(2005, 7).isEqual(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例11
public void testIsAfter_LocalTime() {
LocalTime test1 = new LocalTime(10, 20, 30, 40);
LocalTime test1a = new LocalTime(10, 20, 30, 40);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
LocalTime test2 = new LocalTime(10, 20, 35, 40);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
LocalTime test3 = new LocalTime(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
try {
new LocalTime(10, 20, 35, 40).isAfter(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例12
public void testIsAfter_YM() {
YearMonth test1 = new YearMonth(2005, 6);
YearMonth test1a = new YearMonth(2005, 6);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
YearMonth test2 = new YearMonth(2005, 7);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
YearMonth test3 = new YearMonth(2005, 7, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
try {
new YearMonth(2005, 7).isAfter(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例13
public void testIsBefore_YM() {
YearMonth test1 = new YearMonth(2005, 6);
YearMonth test1a = new YearMonth(2005, 6);
assertEquals(false, test1.isBefore(test1a));
assertEquals(false, test1a.isBefore(test1));
assertEquals(false, test1.isBefore(test1));
assertEquals(false, test1a.isBefore(test1a));
YearMonth test2 = new YearMonth(2005, 7);
assertEquals(true, test1.isBefore(test2));
assertEquals(false, test2.isBefore(test1));
YearMonth test3 = new YearMonth(2005, 7, GregorianChronology.getInstanceUTC());
assertEquals(true, test1.isBefore(test3));
assertEquals(false, test3.isBefore(test1));
assertEquals(false, test3.isBefore(test2));
try {
new YearMonth(2005, 7).isBefore(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例14
public void testIsEqual_TOD() {
TimeOfDay test1 = new TimeOfDay(10, 20, 30, 40);
TimeOfDay test1a = new TimeOfDay(10, 20, 30, 40);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
TimeOfDay test2 = new TimeOfDay(10, 20, 35, 40);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
TimeOfDay test3 = new TimeOfDay(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
try {
new TimeOfDay(10, 20, 35, 40).isEqual(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例15
public void testIsAfter_LocalDate() {
LocalDate test1 = new LocalDate(2005, 6, 2);
LocalDate test1a = new LocalDate(2005, 6, 2);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
LocalDate test2 = new LocalDate(2005, 7, 2);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
LocalDate test3 = new LocalDate(2005, 7, 2, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
try {
new LocalDate(2005, 7, 2).isAfter(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例16
public void testIsEqual_TOD() {
TimeOfDay test1 = new TimeOfDay(10, 20, 30, 40);
TimeOfDay test1a = new TimeOfDay(10, 20, 30, 40);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
TimeOfDay test2 = new TimeOfDay(10, 20, 35, 40);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
TimeOfDay test3 = new TimeOfDay(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
try {
new TimeOfDay(10, 20, 35, 40).isEqual(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例17
public void testIsAfter_TOD() {
TimeOfDay test1 = new TimeOfDay(10, 20, 30, 40);
TimeOfDay test1a = new TimeOfDay(10, 20, 30, 40);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
TimeOfDay test2 = new TimeOfDay(10, 20, 35, 40);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
TimeOfDay test3 = new TimeOfDay(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
try {
new TimeOfDay(10, 20, 35, 40).isAfter(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例18
public void testIsEqual_YMD() {
YearMonthDay test1 = new YearMonthDay(2005, 6, 2);
YearMonthDay test1a = new YearMonthDay(2005, 6, 2);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
YearMonthDay test2 = new YearMonthDay(2005, 7, 2);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
YearMonthDay test3 = new YearMonthDay(2005, 7, 2, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
try {
new YearMonthDay(2005, 7, 2).isEqual(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例19
public void testIsEqual_LocalTime() {
LocalTime test1 = new LocalTime(10, 20, 30, 40);
LocalTime test1a = new LocalTime(10, 20, 30, 40);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
LocalTime test2 = new LocalTime(10, 20, 35, 40);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
LocalTime test3 = new LocalTime(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
try {
new LocalTime(10, 20, 35, 40).isEqual(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例20
public void testIsAfter_RI() {
Instant test1 = new Instant(TEST_TIME1);
Instant test1a = new Instant(TEST_TIME1);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
Instant test2 = new Instant(TEST_TIME2);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
DateTime test3 = new DateTime(TEST_TIME2, GregorianChronology.getInstance(PARIS));
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
assertEquals(true, test2.isAfter(new MockInstant()));
assertEquals(false, test1.isAfter(new MockInstant()));
assertEquals(true, new Instant(TEST_TIME_NOW + 1).isAfter(null));
assertEquals(false, new Instant(TEST_TIME_NOW).isAfter(null));
assertEquals(false, new Instant(TEST_TIME_NOW - 1).isAfter(null));
}
示例21
public void testIsEqual_LocalTime() {
LocalTime test1 = new LocalTime(10, 20, 30, 40);
LocalTime test1a = new LocalTime(10, 20, 30, 40);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
LocalTime test2 = new LocalTime(10, 20, 35, 40);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
LocalTime test3 = new LocalTime(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
try {
new LocalTime(10, 20, 35, 40).isEqual(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例22
public void testIsBefore_LocalTime() {
LocalTime test1 = new LocalTime(10, 20, 30, 40);
LocalTime test1a = new LocalTime(10, 20, 30, 40);
assertEquals(false, test1.isBefore(test1a));
assertEquals(false, test1a.isBefore(test1));
assertEquals(false, test1.isBefore(test1));
assertEquals(false, test1a.isBefore(test1a));
LocalTime test2 = new LocalTime(10, 20, 35, 40);
assertEquals(true, test1.isBefore(test2));
assertEquals(false, test2.isBefore(test1));
LocalTime test3 = new LocalTime(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(true, test1.isBefore(test3));
assertEquals(false, test3.isBefore(test1));
assertEquals(false, test3.isBefore(test2));
try {
new LocalTime(10, 20, 35, 40).isBefore(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例23
public void testIsAfter_LocalTime() {
LocalTime test1 = new LocalTime(10, 20, 30, 40);
LocalTime test1a = new LocalTime(10, 20, 30, 40);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
LocalTime test2 = new LocalTime(10, 20, 35, 40);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
LocalTime test3 = new LocalTime(10, 20, 35, 40, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
try {
new LocalTime(10, 20, 35, 40).isAfter(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例24
public void testBug2182444_usCentral() {
Chronology chronUSCentral = GregorianChronology.getInstance(DateTimeZone.forID("US/Central"));
Chronology chronUTC = GregorianChronology.getInstance(DateTimeZone.UTC);
DateTime usCentralStandardInUTC = new DateTime(2008, 11, 2, 7, 0, 0, 0, chronUTC);
DateTime usCentralDaylightInUTC = new DateTime(2008, 11, 2, 6, 0, 0, 0, chronUTC);
assertTrue("Should be standard time", chronUSCentral.getZone().isStandardOffset(usCentralStandardInUTC.getMillis()));
assertFalse("Should be daylight time", chronUSCentral.getZone().isStandardOffset(usCentralDaylightInUTC.getMillis()));
DateTime usCentralStandardInUSCentral = usCentralStandardInUTC.toDateTime(chronUSCentral);
DateTime usCentralDaylightInUSCentral = usCentralDaylightInUTC.toDateTime(chronUSCentral);
assertEquals(1, usCentralStandardInUSCentral.getHourOfDay());
assertEquals(usCentralStandardInUSCentral.getHourOfDay(), usCentralDaylightInUSCentral.getHourOfDay());
assertTrue(usCentralStandardInUSCentral.getMillis() != usCentralDaylightInUSCentral.getMillis());
assertEquals(usCentralStandardInUSCentral, usCentralStandardInUSCentral.withHourOfDay(1));
assertEquals(usCentralStandardInUSCentral.getMillis() + 3, usCentralStandardInUSCentral.withMillisOfSecond(3).getMillis());
assertEquals(usCentralDaylightInUSCentral, usCentralDaylightInUSCentral.withHourOfDay(1));
assertEquals(usCentralDaylightInUSCentral.getMillis() + 3, usCentralDaylightInUSCentral.withMillisOfSecond(3).getMillis());
}
示例25
public void testIsEqual() {
MutableDateTime test1 = new MutableDateTime(TEST_TIME1);
MutableDateTime test1a = new MutableDateTime(TEST_TIME1);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
MutableDateTime test2 = new MutableDateTime(TEST_TIME2);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
MutableDateTime test3 = new MutableDateTime(TEST_TIME2, GregorianChronology.getInstance(PARIS));
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
assertEquals(false, test2.isEqual(new MockInstant()));
assertEquals(true, test1.isEqual(new MockInstant()));
assertEquals(false, new MutableDateTime(TEST_TIME_NOW + 1).isEqual(null));
assertEquals(true, new MutableDateTime(TEST_TIME_NOW).isEqual(null));
assertEquals(false, new MutableDateTime(TEST_TIME_NOW - 1).isEqual(null));
}
示例26
public void testIsBefore() {
MutableDateTime test1 = new MutableDateTime(TEST_TIME1);
MutableDateTime test1a = new MutableDateTime(TEST_TIME1);
assertEquals(false, test1.isBefore(test1a));
assertEquals(false, test1a.isBefore(test1));
assertEquals(false, test1.isBefore(test1));
assertEquals(false, test1a.isBefore(test1a));
MutableDateTime test2 = new MutableDateTime(TEST_TIME2);
assertEquals(true, test1.isBefore(test2));
assertEquals(false, test2.isBefore(test1));
MutableDateTime test3 = new MutableDateTime(TEST_TIME2, GregorianChronology.getInstance(PARIS));
assertEquals(true, test1.isBefore(test3));
assertEquals(false, test3.isBefore(test1));
assertEquals(false, test3.isBefore(test2));
assertEquals(false, test2.isBefore(new MockInstant()));
assertEquals(false, test1.isBefore(new MockInstant()));
assertEquals(false, new MutableDateTime(TEST_TIME_NOW + 1).isBefore(null));
assertEquals(false, new MutableDateTime(TEST_TIME_NOW).isBefore(null));
assertEquals(true, new MutableDateTime(TEST_TIME_NOW - 1).isBefore(null));
}
示例27
public void testIsAfter() {
MutableDateTime test1 = new MutableDateTime(TEST_TIME1);
MutableDateTime test1a = new MutableDateTime(TEST_TIME1);
assertEquals(false, test1.isAfter(test1a));
assertEquals(false, test1a.isAfter(test1));
assertEquals(false, test1.isAfter(test1));
assertEquals(false, test1a.isAfter(test1a));
MutableDateTime test2 = new MutableDateTime(TEST_TIME2);
assertEquals(false, test1.isAfter(test2));
assertEquals(true, test2.isAfter(test1));
MutableDateTime test3 = new MutableDateTime(TEST_TIME2, GregorianChronology.getInstance(PARIS));
assertEquals(false, test1.isAfter(test3));
assertEquals(true, test3.isAfter(test1));
assertEquals(false, test3.isAfter(test2));
assertEquals(true, test2.isAfter(new MockInstant()));
assertEquals(false, test1.isAfter(new MockInstant()));
assertEquals(true, new MutableDateTime(TEST_TIME_NOW + 1).isAfter(null));
assertEquals(false, new MutableDateTime(TEST_TIME_NOW).isAfter(null));
assertEquals(false, new MutableDateTime(TEST_TIME_NOW - 1).isAfter(null));
}
示例28
public void testBug2182444_usCentral() {
Chronology chronUSCentral = GregorianChronology.getInstance(DateTimeZone.forID("US/Central"));
Chronology chronUTC = GregorianChronology.getInstance(DateTimeZone.UTC);
DateTime usCentralStandardInUTC = new DateTime(2008, 11, 2, 7, 0, 0, 0, chronUTC);
DateTime usCentralDaylightInUTC = new DateTime(2008, 11, 2, 6, 0, 0, 0, chronUTC);
assertTrue("Should be standard time", chronUSCentral.getZone().isStandardOffset(usCentralStandardInUTC.getMillis()));
assertFalse("Should be daylight time", chronUSCentral.getZone().isStandardOffset(usCentralDaylightInUTC.getMillis()));
DateTime usCentralStandardInUSCentral = usCentralStandardInUTC.toDateTime(chronUSCentral);
DateTime usCentralDaylightInUSCentral = usCentralDaylightInUTC.toDateTime(chronUSCentral);
assertEquals(1, usCentralStandardInUSCentral.getHourOfDay());
assertEquals(usCentralStandardInUSCentral.getHourOfDay(), usCentralDaylightInUSCentral.getHourOfDay());
assertTrue(usCentralStandardInUSCentral.getMillis() != usCentralDaylightInUSCentral.getMillis());
assertEquals(usCentralStandardInUSCentral, usCentralStandardInUSCentral.withHourOfDay(1));
assertEquals(usCentralStandardInUSCentral.getMillis() + 3, usCentralStandardInUSCentral.withMillisOfSecond(3).getMillis());
assertEquals(usCentralDaylightInUSCentral, usCentralDaylightInUSCentral.withHourOfDay(1));
assertEquals(usCentralDaylightInUSCentral.getMillis() + 3, usCentralDaylightInUSCentral.withMillisOfSecond(3).getMillis());
}
示例29
public void testIsBefore_LocalDate() {
LocalDate test1 = new LocalDate(2005, 6, 2);
LocalDate test1a = new LocalDate(2005, 6, 2);
assertEquals(false, test1.isBefore(test1a));
assertEquals(false, test1a.isBefore(test1));
assertEquals(false, test1.isBefore(test1));
assertEquals(false, test1a.isBefore(test1a));
LocalDate test2 = new LocalDate(2005, 7, 2);
assertEquals(true, test1.isBefore(test2));
assertEquals(false, test2.isBefore(test1));
LocalDate test3 = new LocalDate(2005, 7, 2, GregorianChronology.getInstanceUTC());
assertEquals(true, test1.isBefore(test3));
assertEquals(false, test3.isBefore(test1));
assertEquals(false, test3.isBefore(test2));
try {
new LocalDate(2005, 7, 2).isBefore(null);
fail();
} catch (IllegalArgumentException ex) {}
}
示例30
public void testIsEqual_YMD() {
YearMonthDay test1 = new YearMonthDay(2005, 6, 2);
YearMonthDay test1a = new YearMonthDay(2005, 6, 2);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(true, test1.isEqual(test1));
assertEquals(true, test1a.isEqual(test1a));
YearMonthDay test2 = new YearMonthDay(2005, 7, 2);
assertEquals(false, test1.isEqual(test2));
assertEquals(false, test2.isEqual(test1));
YearMonthDay test3 = new YearMonthDay(2005, 7, 2, GregorianChronology.getInstanceUTC());
assertEquals(false, test1.isEqual(test3));
assertEquals(false, test3.isEqual(test1));
assertEquals(true, test3.isEqual(test2));
try {
new YearMonthDay(2005, 7, 2).isEqual(null);
fail();
} catch (IllegalArgumentException ex) {}
}