use of org.joda.time.MutablePeriod in project joda-time by JodaOrg.
the class TestPeriodFormatter method testParseMutablePeriod_simple.
//-----------------------------------------------------------------------
public void testParseMutablePeriod_simple() {
MutablePeriod expect = new MutablePeriod(1, 2, 3, 4, 5, 6, 7, 8);
assertEquals(expect, f.parseMutablePeriod("P1Y2M3W4DT5H6M7.008S"));
try {
f.parseMutablePeriod("ABC");
fail();
} catch (IllegalArgumentException ex) {
}
}
use of org.joda.time.MutablePeriod in project joda-time by JodaOrg.
the class TestReadableDurationConverter method testSetInto_Object.
public void testSetInto_Object() throws Exception {
MutablePeriod m = new MutablePeriod(PeriodType.yearMonthDayTime());
ReadableDurationConverter.INSTANCE.setInto(m, new Duration(3L * DateTimeConstants.MILLIS_PER_DAY + 4L * DateTimeConstants.MILLIS_PER_MINUTE + 5L), null);
assertEquals(0, m.getYears());
assertEquals(0, m.getMonths());
assertEquals(0, m.getWeeks());
assertEquals(0, m.getDays());
assertEquals(3 * 24, m.getHours());
assertEquals(4, m.getMinutes());
assertEquals(0, m.getSeconds());
assertEquals(5, m.getMillis());
}
use of org.joda.time.MutablePeriod in project joda-time by JodaOrg.
the class TestStringConverter method testSetIntoPeriod_Object4.
public void testSetIntoPeriod_Object4() throws Exception {
MutablePeriod m = new MutablePeriod(PeriodType.yearWeekDayTime());
StringConverter.INSTANCE.setInto(m, "P2Y4W3DT12H24M.056S", null);
assertEquals(2, m.getYears());
assertEquals(4, m.getWeeks());
assertEquals(3, m.getDays());
assertEquals(12, m.getHours());
assertEquals(24, m.getMinutes());
assertEquals(0, m.getSeconds());
assertEquals(56, m.getMillis());
}
use of org.joda.time.MutablePeriod in project joda-time by JodaOrg.
the class TestStringConverter method testSetIntoPeriod_Object1.
public void testSetIntoPeriod_Object1() throws Exception {
MutablePeriod m = new MutablePeriod(PeriodType.yearMonthDayTime());
StringConverter.INSTANCE.setInto(m, "P2Y6M9DT12H24M48S", null);
assertEquals(2, m.getYears());
assertEquals(6, m.getMonths());
assertEquals(9, m.getDays());
assertEquals(12, m.getHours());
assertEquals(24, m.getMinutes());
assertEquals(48, m.getSeconds());
assertEquals(0, m.getMillis());
}
use of org.joda.time.MutablePeriod in project joda-time by JodaOrg.
the class TestStringConverter method testSetIntoPeriod_Object3.
public void testSetIntoPeriod_Object3() throws Exception {
MutablePeriod m = new MutablePeriod(PeriodType.yearWeekDayTime());
StringConverter.INSTANCE.setInto(m, "P2Y4W3DT12H24M48.034S", null);
assertEquals(2, m.getYears());
assertEquals(4, m.getWeeks());
assertEquals(3, m.getDays());
assertEquals(12, m.getHours());
assertEquals(24, m.getMinutes());
assertEquals(48, m.getSeconds());
assertEquals(34, m.getMillis());
}
Aggregations