Search in sources :

Example 1 with ReadableInterval

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

the class ReadableIntervalConverter method setInto.

/**
     * Extracts interval endpoint values from an object of this converter's
     * type, and sets them into the given ReadWritableInterval.
     *
     * @param writableInterval interval to get modified, not null
     * @param object  the object to convert, must not be null
     * @param chrono  the chronology to use, may be null
     * @throws ClassCastException if the object is invalid
     */
public void setInto(ReadWritableInterval writableInterval, Object object, Chronology chrono) {
    ReadableInterval input = (ReadableInterval) object;
    writableInterval.setInterval(input);
    if (chrono != null) {
        writableInterval.setChronology(chrono);
    } else {
        writableInterval.setChronology(input.getChronology());
    }
}
Also used : ReadableInterval(org.joda.time.ReadableInterval)

Example 2 with ReadableInterval

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

the class ReadableIntervalConverter method setInto.

//-----------------------------------------------------------------------
/**
     * Sets the values of the mutable duration from the specified interval.
     * 
     * @param writablePeriod  the period to modify
     * @param object  the interval to set from
     * @param chrono  the chronology to use
     */
public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) {
    ReadableInterval interval = (ReadableInterval) object;
    chrono = (chrono != null ? chrono : DateTimeUtils.getIntervalChronology(interval));
    long start = interval.getStartMillis();
    long end = interval.getEndMillis();
    int[] values = chrono.get(writablePeriod, start, end);
    for (int i = 0; i < values.length; i++) {
        writablePeriod.setValue(i, values[i]);
    }
}
Also used : ReadableInterval(org.joda.time.ReadableInterval)

Aggregations

ReadableInterval (org.joda.time.ReadableInterval)2