當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTimeUtils.isContiguous方法代碼示例

本文整理匯總了Java中org.joda.time.DateTimeUtils.isContiguous方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeUtils.isContiguous方法的具體用法?Java DateTimeUtils.isContiguous怎麽用?Java DateTimeUtils.isContiguous使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.DateTimeUtils的用法示例。


在下文中一共展示了DateTimeUtils.isContiguous方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: between

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
/**
 * Calculates the number of whole units between the two specified partial datetimes.
 * <p>
 * The two partials must contain the same fields, for example you can specify
 * two <code>LocalDate</code> objects.
 *
 * @param start  the start partial date, validated to not be null
 * @param end  the end partial date, validated to not be null
 * @param zeroInstance  the zero instance constant, must not be null
 * @return the period
 * @throws IllegalArgumentException if the partials are null or invalid
 */
protected static int between(ReadablePartial start, ReadablePartial end, ReadablePeriod zeroInstance) {
    if (start == null || end == null) {
        throw new IllegalArgumentException("ReadablePartial objects must not be null");
    }
    if (start.size() != end.size()) {
        throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
    }
    for (int i = 0, isize = start.size(); i < isize; i++) {
        if (start.getFieldType(i) != end.getFieldType(i)) {
            throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
        }
    }
    if (DateTimeUtils.isContiguous(start) == false) {
        throw new IllegalArgumentException("ReadablePartial objects must be contiguous");
    }
    Chronology chrono = DateTimeUtils.getChronology(start.getChronology()).withUTC();
    int[] values = chrono.get(zeroInstance, chrono.set(start, 0L), chrono.set(end, 0L));
    return values[0];
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:32,代碼來源:BaseSingleFieldPeriod.java

示例2: add

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
public int[] add(ReadablePartial partial, int fieldIndex, int[] values, int valueToAdd) {
    // overridden as superclass algorithm can't handle
    // 2004-02-29 + 48 months -> 2008-02-29 type dates
    if (valueToAdd == 0) {
        return values;
    }
    if (DateTimeUtils.isContiguous(partial)) {
        long instant = 0L;
        for (int i = 0, isize = partial.size(); i < isize; i++) {
            instant = partial.getFieldType(i).getField(GJChronology.this).set(instant, values[i]);
        }
        instant = add(instant, valueToAdd);
        return GJChronology.this.get(partial, instant);
    } else {
        return super.add(partial, fieldIndex, values, valueToAdd);
    }
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:18,代碼來源:GJChronology.java

示例3: add

import org.joda.time.DateTimeUtils; //導入方法依賴的package包/類
public int[] add(ReadablePartial partial, int fieldIndex, int[] values, int valueToAdd) {
    // overridden as superclass algorithm can't handle
    // 2004-02-29 + 48 months -> 2008-02-29 type dates
    if (valueToAdd == 0) {
        return values;
    }
    if (DateTimeUtils.isContiguous(partial)) {
        long instant = 0L;
        for (int i = 0, isize = partial.size(); i < isize; i++) {
            instant = partial.getFieldType(i).getField(iChronology).set(instant, values[i]);
        }
        instant = add(instant, valueToAdd);
        return iChronology.get(partial, instant);
    } else {
        return super.add(partial, fieldIndex, values, valueToAdd);
    }
}
 
開發者ID:redfish64,項目名稱:TinyTravelTracker,代碼行數:18,代碼來源:BasicMonthOfYearDateTimeField.java


注:本文中的org.joda.time.DateTimeUtils.isContiguous方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。