use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestConverterManager method testGetPartialConverterBadMultipleMatches.
public void testGetPartialConverterBadMultipleMatches() {
PartialConverter c = new PartialConverter() {
public int[] getPartialValues(ReadablePartial partial, Object object, Chronology chrono) {
return null;
}
public int[] getPartialValues(ReadablePartial partial, Object object, Chronology chrono, DateTimeFormatter parser) {
return null;
}
public Chronology getChronology(Object object, DateTimeZone zone) {
return null;
}
public Chronology getChronology(Object object, Chronology chrono) {
return null;
}
public Class getSupportedType() {
return Serializable.class;
}
};
try {
ConverterManager.getInstance().addPartialConverter(c);
try {
ConverterManager.getInstance().getPartialConverter(new DateTime());
fail();
} catch (IllegalStateException ex) {
// Serializable and ReadablePartial both match, so cannot pick
}
} finally {
ConverterManager.getInstance().removePartialConverter(c);
}
assertEquals(PARTIAL_SIZE, ConverterManager.getInstance().getPartialConverters().length);
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestConverterManager method testGetPartialConverterOKMultipleMatches.
public void testGetPartialConverterOKMultipleMatches() {
PartialConverter c = new PartialConverter() {
public int[] getPartialValues(ReadablePartial partial, Object object, Chronology chrono) {
return null;
}
public int[] getPartialValues(ReadablePartial partial, Object object, Chronology chrono, DateTimeFormatter parser) {
return null;
}
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().addPartialConverter(c);
PartialConverter ok = ConverterManager.getInstance().getPartialConverter(new DateTime());
// ReadableDateTime and ReadablePartial both match, but RI discarded as less specific
assertEquals(ReadableDateTime.class, ok.getSupportedType());
} finally {
ConverterManager.getInstance().removePartialConverter(c);
}
assertEquals(PARTIAL_SIZE, ConverterManager.getInstance().getPartialConverters().length);
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestDateConverter method testGetInstantMillis_Object_Chronology.
//-----------------------------------------------------------------------
public void testGetInstantMillis_Object_Chronology() throws Exception {
Date date = new Date(123L);
long millis = DateConverter.INSTANCE.getInstantMillis(date, JULIAN);
assertEquals(123L, millis);
assertEquals(123L, DateConverter.INSTANCE.getInstantMillis(date, (Chronology) null));
}
use of org.joda.time.Chronology in project joda-time by JodaOrg.
the class TestISOChronology method testLeap_29feb.
public void testLeap_29feb() {
Chronology chrono = ISOChronology.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 TestJulianChronology method testLeap_28feb.
public void testLeap_28feb() {
Chronology chrono = JulianChronology.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());
}
Aggregations