use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestConverterManager method testGetInstantConverterOKMultipleMatches.
public void testGetInstantConverterOKMultipleMatches() {
InstantConverter c = new InstantConverter() {
public long getInstantMillis(Object object, Chronology chrono) {
return 0;
}
public Chronology getChronology(Object object, DateTimeZone zone) {
return null;
}
public Chronology getChronology(Object object, Chronology chrono) {
return null;
}
public Class getSupportedType() {
return ReadableDateTime.class;
}
};
try {
ConverterManager.getInstance().addInstantConverter(c);
InstantConverter ok = ConverterManager.getInstance().getInstantConverter(new DateTime());
// ReadableDateTime and ReadableInstant both match, but RI discarded as less specific
assertEquals(ReadableDateTime.class, ok.getSupportedType());
} finally {
ConverterManager.getInstance().removeInstantConverter(c);
}
assertEquals(6, ConverterManager.getInstance().getInstantConverters().length);
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestISOChronology method testLeap_28feb.
public void testLeap_28feb() {
Chronology chrono = ISOChronology.getInstance();
DateTime dt = new DateTime(2012, 2, 28, 0, 0, chrono);
assertEquals(true, dt.year().isLeap());
assertEquals(true, dt.monthOfYear().isLeap());
assertEquals(false, dt.dayOfMonth().isLeap());
assertEquals(false, dt.dayOfYear().isLeap());
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestJulianChronology method testLeap_29feb.
public void testLeap_29feb() {
Chronology chrono = JulianChronology.getInstance();
DateTime dt = new DateTime(2012, 2, 29, 0, 0, chrono);
assertEquals(true, dt.year().isLeap());
assertEquals(true, dt.monthOfYear().isLeap());
assertEquals(true, dt.dayOfMonth().isLeap());
assertEquals(true, dt.dayOfYear().isLeap());
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestLenientChronology method test_lenientChrononolgy_Chicago.
public void test_lenientChrononolgy_Chicago() {
DateTimeZone zone = DateTimeZone.forID("America/Chicago");
Chronology lenient = LenientChronology.getInstance(ISOChronology.getInstance(zone));
DateTime dt = new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
assertEquals("2007-03-11T03:30:00.000-05:00", dt.toString());
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestLenientChronology method test_strictChrononolgy_Chicago.
public void test_strictChrononolgy_Chicago() {
DateTimeZone zone = DateTimeZone.forID("America/Chicago");
Chronology lenient = StrictChronology.getInstance(ISOChronology.getInstance(zone));
try {
new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
fail();
} catch (IllegalArgumentException ex) {
// expected
}
}
Aggregations