Search in sources :

Example 1 with MutablePeriod

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) {
    }
}
Also used : MutablePeriod(org.joda.time.MutablePeriod)

Example 2 with MutablePeriod

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());
}
Also used : MutablePeriod(org.joda.time.MutablePeriod) ReadableDuration(org.joda.time.ReadableDuration) Duration(org.joda.time.Duration)

Example 3 with MutablePeriod

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());
}
Also used : MutablePeriod(org.joda.time.MutablePeriod)

Example 4 with MutablePeriod

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());
}
Also used : MutablePeriod(org.joda.time.MutablePeriod)

Example 5 with MutablePeriod

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());
}
Also used : MutablePeriod(org.joda.time.MutablePeriod)

Aggregations

MutablePeriod (org.joda.time.MutablePeriod)18 Duration (org.joda.time.Duration)2 Interval (org.joda.time.Interval)2 MutableInterval (org.joda.time.MutableInterval)2 ReadableInterval (org.joda.time.ReadableInterval)2 DateTime (org.joda.time.DateTime)1 Period (org.joda.time.Period)1 ReadableDuration (org.joda.time.ReadableDuration)1 ReadablePeriod (org.joda.time.ReadablePeriod)1 PeriodFormatterBuilder (org.joda.time.format.PeriodFormatterBuilder)1 PeriodParser (org.joda.time.format.PeriodParser)1