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


Java Temporal.plus方法代碼示例

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


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

示例1: addTo

import java.time.temporal.Temporal; //導入方法依賴的package包/類
@Override
public Temporal addTo(Temporal temporal) {
    validateChrono(temporal);
    if (months == 0) {
        if (years != 0) {
            temporal = temporal.plus(years, YEARS);
        }
    } else {
        long monthRange = monthRange();
        if (monthRange > 0) {
            temporal = temporal.plus(years * monthRange + months, MONTHS);
        } else {
            if (years != 0) {
                temporal = temporal.plus(years, YEARS);
            }
            temporal = temporal.plus(months, MONTHS);
        }
    }
    if (days != 0) {
        temporal = temporal.plus(days, DAYS);
    }
    return temporal;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:24,代碼來源:ChronoPeriodImpl.java

示例2: addTo

import java.time.temporal.Temporal; //導入方法依賴的package包/類
@Override
public Temporal addTo(Temporal temporal) {
    for(Map.Entry<TemporalUnit, Long> entry : values.entrySet()) {
        temporal = temporal.plus(entry.getValue(), entry.getKey());
    }
    return temporal;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:TimePeriod.java

示例3: bepaalPeilmoment

import java.time.temporal.Temporal; //導入方法依賴的package包/類
private static <T extends Temporal> T bepaalPeilmoment(T peilmoment, Integer interval, ChronoUnit chronoUnit,
                                                       Integer aantalPeriodesVerschilMetOrigineel, Class<T> clazz) {
    Temporal nieuwPeilmoment = peilmoment;
    if (interval != null && chronoUnit != null && aantalPeriodesVerschilMetOrigineel != null) {
        nieuwPeilmoment =
                nieuwPeilmoment.plus((long) aantalPeriodesVerschilMetOrigineel * interval, chronoUnit);
    }
    return clazz.cast(nieuwPeilmoment);
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:10,代碼來源:SelectieTaakBerekenServiceImpl.java

示例4: addTo

import java.time.temporal.Temporal; //導入方法依賴的package包/類
@Override
public Temporal addTo(Temporal temporal) {
    return temporal.plus(value, unit);
}
 
開發者ID:StefaniniInspiring,項目名稱:pugtsdb,代碼行數:5,代碼來源:Retention.java

示例5: addTo

import java.time.temporal.Temporal; //導入方法依賴的package包/類
/**
 * Adds this period to the specified temporal object.
 * <p>
 * This returns a temporal object of the same observable type as the input
 * with this period added.
 * If the temporal has a chronology, it must be the ISO chronology.
 * <p>
 * In most cases, it is clearer to reverse the calling pattern by using
 * {@link Temporal#plus(TemporalAmount)}.
 * <pre>
 *   // these two lines are equivalent, but the second approach is recommended
 *   dateTime = thisPeriod.addTo(dateTime);
 *   dateTime = dateTime.plus(thisPeriod);
 * </pre>
 * <p>
 * The calculation operates as follows.
 * First, the chronology of the temporal is checked to ensure it is ISO chronology or null.
 * Second, if the months are zero, the years are added if non-zero, otherwise
 * the combination of years and months is added if non-zero.
 * Finally, any days are added.
 * <p>
 * This approach ensures that a partial period can be added to a partial date.
 * For example, a period of years and/or months can be added to a {@code YearMonth},
 * but a period including days cannot.
 * The approach also adds years and months together when necessary, which ensures
 * correct behaviour at the end of the month.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param temporal  the temporal object to adjust, not null
 * @return an object of the same type with the adjustment made, not null
 * @throws DateTimeException if unable to add
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Temporal addTo(Temporal temporal) {
    validateChrono(temporal);
    if (months == 0) {
        if (years != 0) {
            temporal = temporal.plus(years, YEARS);
        }
    } else {
        long totalMonths = toTotalMonths();
        if (totalMonths != 0) {
            temporal = temporal.plus(totalMonths, MONTHS);
        }
    }
    if (days != 0) {
        temporal = temporal.plus(days, DAYS);
    }
    return temporal;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:53,代碼來源:Period.java

示例6: addTo

import java.time.temporal.Temporal; //導入方法依賴的package包/類
@Override
public Temporal addTo(Temporal temporal) {
    return temporal.plus(amount, unit);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:MockSimplePeriod.java

示例7: addTo

import java.time.temporal.Temporal; //導入方法依賴的package包/類
/**
 * Adds this duration to the specified temporal object.
 * <p>
 * This returns a temporal object of the same observable type as the input
 * with this duration added.
 * <p>
 * In most cases, it is clearer to reverse the calling pattern by using
 * {@link Temporal#plus(TemporalAmount)}.
 * <pre>
 *   // these two lines are equivalent, but the second approach is recommended
 *   dateTime = thisDuration.addTo(dateTime);
 *   dateTime = dateTime.plus(thisDuration);
 * </pre>
 * <p>
 * The calculation will add the seconds, then nanos.
 * Only non-zero amounts will be added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param temporal  the temporal object to adjust, not null
 * @return an object of the same type with the adjustment made, not null
 * @throws DateTimeException if unable to add
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Temporal addTo(Temporal temporal) {
    if (seconds != 0) {
        temporal = temporal.plus(seconds, SECONDS);
    }
    if (nanos != 0) {
        temporal = temporal.plus(nanos, NANOS);
    }
    return temporal;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:35,代碼來源:Duration.java


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