Java Code Examples for org.joda.time.DateTimeUtils#getIntervalChronology()

The following examples show how to use org.joda.time.DateTimeUtils#getIntervalChronology() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Time_22_BasePeriod_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a period from the given interval endpoints.
 *
 * @param startInstant  interval start, null means now
 * @param endInstant  interval end, null means now
 * @param type  which set of fields this period supports, null means standard
 * @throws IllegalArgumentException if period type is invalid
 */
protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) {
    super();
    type = checkPeriodType(type);
    if (startInstant == null && endInstant == null) {
        iType = type;
        iValues = new int[size()];
    } else {
        long startMillis = DateTimeUtils.getInstantMillis(startInstant);
        long endMillis = DateTimeUtils.getInstantMillis(endInstant);
        Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant);
        iType = type;
        iValues = chrono.get(this, startMillis, endMillis);
    }
}
 
Example 2
Source File: Time_22_BasePeriod_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Creates a period from the given interval endpoints.
 *
 * @param startInstant  interval start, null means now
 * @param endInstant  interval end, null means now
 * @param type  which set of fields this period supports, null means standard
 * @throws IllegalArgumentException if period type is invalid
 */
protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) {
    super();
    type = checkPeriodType(type);
    if (startInstant == null && endInstant == null) {
        iType = type;
        iValues = new int[size()];
    } else {
        long startMillis = DateTimeUtils.getInstantMillis(startInstant);
        long endMillis = DateTimeUtils.getInstantMillis(endInstant);
        Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant);
        iType = type;
        iValues = chrono.get(this, startMillis, endMillis);
    }
}
 
Example 3
Source File: BasePeriod.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a period from the given interval endpoints.
 *
 * @param startInstant  interval start, null means now
 * @param endInstant  interval end, null means now
 * @param type  which set of fields this period supports, null means standard
 * @throws IllegalArgumentException if period type is invalid
 */
protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) {
    super();
    type = checkPeriodType(type);
    if (startInstant == null && endInstant == null) {
        iType = type;
        iValues = new int[size()];
    } else {
        long startMillis = DateTimeUtils.getInstantMillis(startInstant);
        long endMillis = DateTimeUtils.getInstantMillis(endInstant);
        Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant);
        iType = type;
        iValues = chrono.get(this, startMillis, endMillis);
    }
}
 
Example 4
Source File: ReadableIntervalConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 5
Source File: BasePeriod.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a period from the given interval endpoints.
 *
 * @param startInstant  interval start, null means now
 * @param endInstant  interval end, null means now
 * @param type  which set of fields this period supports, null means standard
 * @throws IllegalArgumentException if period type is invalid
 */
protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) {
    super();
    type = checkPeriodType(type);
    if (startInstant == null && endInstant == null) {
        iType = type;
        iValues = new int[size()];
    } else {
        long startMillis = DateTimeUtils.getInstantMillis(startInstant);
        long endMillis = DateTimeUtils.getInstantMillis(endInstant);
        Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant);
        iType = type;
        iValues = chrono.get(this, startMillis, endMillis);
    }
}
 
Example 6
Source File: ReadableIntervalConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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]);
    }
}