Search in sources :

Example 16 with MutablePeriod

use of org.joda.time.MutablePeriod in project joda-time by JodaOrg.

the class TestPeriodFormatter method testParseInto_simple.

//-----------------------------------------------------------------------
public void testParseInto_simple() {
    MutablePeriod expect = new MutablePeriod(1, 2, 3, 4, 5, 6, 7, 8);
    MutablePeriod result = new MutablePeriod();
    assertEquals(20, f.parseInto(result, "P1Y2M3W4DT5H6M7.008S", 0));
    assertEquals(expect, result);
    try {
        f.parseInto(null, "P1Y2M3W4DT5H6M7.008S", 0);
        fail();
    } catch (IllegalArgumentException ex) {
    }
    assertEquals(~0, f.parseInto(result, "ABC", 0));
}
Also used : MutablePeriod(org.joda.time.MutablePeriod)

Example 17 with MutablePeriod

use of org.joda.time.MutablePeriod in project joda-time by JodaOrg.

the class BaseSingleFieldPeriod method toMutablePeriod.

/**
     * Get this object as a <code>MutablePeriod</code>.
     * <p>
     * This will always return a new <code>MutablePeriod</code> with the same fields.
     * The period will use <code>PeriodType.standard()</code>.
     * 
     * @return a MutablePeriod using the same field set and values
     */
public MutablePeriod toMutablePeriod() {
    MutablePeriod period = new MutablePeriod();
    period.add(this);
    return period;
}
Also used : MutablePeriod(org.joda.time.MutablePeriod)

Aggregations

MutablePeriod (org.joda.time.MutablePeriod)17 Interval (org.joda.time.Interval)2 MutableInterval (org.joda.time.MutableInterval)2 ReadableInterval (org.joda.time.ReadableInterval)2 Duration (org.joda.time.Duration)1 Period (org.joda.time.Period)1 ReadableDuration (org.joda.time.ReadableDuration)1 ReadablePeriod (org.joda.time.ReadablePeriod)1