use of org.joda.time.YearMonthDay in project joda-time by JodaOrg.
the class TestGregorianChronology method testMaximumValue.
public void testMaximumValue() {
YearMonthDay ymd1 = new YearMonthDay(1999, DateTimeConstants.FEBRUARY, 1);
DateMidnight dm1 = new DateMidnight(1999, DateTimeConstants.FEBRUARY, 1);
Chronology chrono = GregorianChronology.getInstance();
assertEquals(28, chrono.dayOfMonth().getMaximumValue(ymd1));
assertEquals(28, chrono.dayOfMonth().getMaximumValue(dm1.getMillis()));
}
use of org.joda.time.YearMonthDay in project joda-time by JodaOrg.
the class TestGJChronology method testAdd.
private void testAdd(String start, DurationFieldType type, int amt, String end) {
DateTime dtStart = new DateTime(start, GJChronology.getInstance(DateTimeZone.UTC));
DateTime dtEnd = new DateTime(end, GJChronology.getInstance(DateTimeZone.UTC));
assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));
DurationField field = type.getField(GJChronology.getInstance(DateTimeZone.UTC));
int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
assertEquals(amt, diff);
if (type == DurationFieldType.years() || type == DurationFieldType.months() || type == DurationFieldType.days()) {
YearMonthDay ymdStart = new YearMonthDay(start, GJChronology.getInstance(DateTimeZone.UTC));
YearMonthDay ymdEnd = new YearMonthDay(end, GJChronology.getInstance(DateTimeZone.UTC));
assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
}
}
use of org.joda.time.YearMonthDay in project joda-time by JodaOrg.
the class TestISOChronology method testMaximumValue.
public void testMaximumValue() {
DateMidnight dt = new DateMidnight(1570, 1, 1);
while (dt.getYear() < 1590) {
dt = dt.plusDays(1);
YearMonthDay ymd = dt.toYearMonthDay();
assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue());
assertEquals(dt.monthOfYear().getMaximumValue(), ymd.monthOfYear().getMaximumValue());
assertEquals(dt.dayOfMonth().getMaximumValue(), ymd.dayOfMonth().getMaximumValue());
}
}
use of org.joda.time.YearMonthDay in project joda-time by JodaOrg.
the class TestReadablePartialConverter method testGetPartialValues.
//-----------------------------------------------------------------------
public void testGetPartialValues() throws Exception {
TimeOfDay tod = new TimeOfDay();
int[] expected = new int[] { 1, 2, 3, 4 };
int[] actual = ReadablePartialConverter.INSTANCE.getPartialValues(tod, new TimeOfDay(1, 2, 3, 4), ISOChronology.getInstance(PARIS));
assertEquals(true, Arrays.equals(expected, actual));
try {
ReadablePartialConverter.INSTANCE.getPartialValues(tod, new YearMonthDay(2005, 6, 9), JULIAN);
fail();
} catch (IllegalArgumentException ex) {
}
try {
ReadablePartialConverter.INSTANCE.getPartialValues(tod, new MockTOD(), JULIAN);
fail();
} catch (IllegalArgumentException ex) {
}
}
use of org.joda.time.YearMonthDay in project joda-time by JodaOrg.
the class TestISOChronology method testAdd.
private void testAdd(String start, DurationFieldType type, int amt, String end) {
DateTime dtStart = new DateTime(start, ISOChronology.getInstanceUTC());
DateTime dtEnd = new DateTime(end, ISOChronology.getInstanceUTC());
assertEquals(dtEnd, dtStart.withFieldAdded(type, amt));
assertEquals(dtStart, dtEnd.withFieldAdded(type, -amt));
DurationField field = type.getField(ISOChronology.getInstanceUTC());
int diff = field.getDifference(dtEnd.getMillis(), dtStart.getMillis());
assertEquals(amt, diff);
if (type == DurationFieldType.years() || type == DurationFieldType.months() || type == DurationFieldType.days()) {
YearMonthDay ymdStart = new YearMonthDay(start, ISOChronology.getInstanceUTC());
YearMonthDay ymdEnd = new YearMonthDay(end, ISOChronology.getInstanceUTC());
assertEquals(ymdEnd, ymdStart.withFieldAdded(type, amt));
assertEquals(ymdStart, ymdEnd.withFieldAdded(type, -amt));
}
}
Aggregations