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


Java LocalTime.minus方法代碼示例

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


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

示例1: testRangeOfLocalTimes

import java.time.LocalTime; //導入方法依賴的package包/類
@Test(dataProvider = "localTimeRanges")
public void testRangeOfLocalTimes(LocalTime start, LocalTime end, Duration step, boolean parallel) {
    final Range<LocalTime> range = Range.of(start, end, step);
    final Array<LocalTime> array = range.toArray(parallel);
    final boolean ascend = start.isBefore(end);
    final int expectedLength = (int)Math.ceil(Math.abs((double)ChronoUnit.SECONDS.between(start, end)) / (double)step.getSeconds());
    Assert.assertEquals(array.length(), expectedLength);
    Assert.assertEquals(array.typeCode(), ArrayType.LOCAL_TIME);
    Assert.assertTrue(!array.style().isSparse());
    Assert.assertEquals(range.start(), start, "The range start");
    Assert.assertEquals(range.end(), end, "The range end");
    LocalTime expected = null;
    for (int i=0; i<array.length(); ++i) {
        final LocalTime actual = array.getValue(i);
        expected = expected == null ? start : ascend ? expected.plus(step) : expected.minus(step);
        Assert.assertEquals(actual, expected, "Value matches at " + i);
        Assert.assertTrue(ascend ? actual.compareTo(start) >=0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + i);
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:20,代碼來源:RangeBasicTests.java

示例2: testRangeOfLocalTimes

import java.time.LocalTime; //導入方法依賴的package包/類
@Test(dataProvider = "LocalTimeRanges")
public void testRangeOfLocalTimes(LocalTime start, LocalTime end, Duration step, boolean parallel) {
    final boolean ascend = start.isBefore(end);
    final Range<LocalTime> range = Range.of(start, end, step, v -> v.getHour() == 6);
    final Array<LocalTime> array = range.toArray(parallel);
    final LocalTime first = array.first(v -> true).map(ArrayValue::getValue).get();
    final LocalTime last = array.last(v -> true).map(ArrayValue::getValue).get();
    Assert.assertEquals(array.typeCode(), ArrayType.LOCAL_TIME);
    Assert.assertTrue(!array.style().isSparse());
    Assert.assertEquals(range.start(), start, "The range start");
    Assert.assertEquals(range.end(), end, "The range end");
    int index = 0;
    LocalTime value = first;
    while (ascend ? value.isBefore(last) : value.isAfter(last)) {
        final LocalTime actual = array.getValue(index);
        Assert.assertEquals(actual, value, "Value matches at " + index);
        Assert.assertTrue(ascend ? actual.compareTo(start) >= 0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + index);
        value = ascend ? value.plus(step) : value.minus(step);
        while (value.getHour() == 6) value = ascend ? value.plus(step) : value.minus(step);
        index++;
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:23,代碼來源:RangeFilterTests.java

示例3: EventTimePointFilter

import java.time.LocalTime; //導入方法依賴的package包/類
public EventTimePointFilter(VaultEntryType vaultEntryType, LocalTime timePoint, int marginInMinutes) {
    this.marginInMinutes = marginInMinutes;
    startTime = timePoint.minus(marginInMinutes, ChronoUnit.MINUTES);
    endTime= timePoint.plus(marginInMinutes, ChronoUnit.MINUTES);
    this.vaultEntryType = vaultEntryType;
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:7,代碼來源:EventTimePointFilter.java

示例4: TimePointFilter

import java.time.LocalTime; //導入方法依賴的package包/類
public TimePointFilter(LocalTime timePoint, int marginInMinutes) {
    LocalTime startTime = timePoint.minus(marginInMinutes, ChronoUnit.MINUTES);
    LocalTime endTime = timePoint.plus(marginInMinutes, ChronoUnit.MINUTES);
    filter = new TimeSpanFilter(startTime, endTime);
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:6,代碼來源:TimePointFilter.java

示例5: localTimeMinus

import java.time.LocalTime; //導入方法依賴的package包/類
@Koan
public void localTimeMinus() {
    LocalTime t1 = LocalTime.parse("10:30");
    LocalTime t2 = t1.minus(2, ChronoUnit.HOURS);
    assertEquals(t2, LocalTime.parse(__));
}
 
開發者ID:linbin0107,項目名稱:koans,代碼行數:7,代碼來源:AboutLocalTime.java

示例6: TimePointFilter

import java.time.LocalTime; //導入方法依賴的package包/類
/**
 * Initialize fields and calculates:
 * <p>
 * startTime: timepoint- marginBeforeInMinutes<p>
 * endTime: timepoint+ marginAfterInMinutes
 *
 * @param timePoint
 * @param marginBeforeInMinutes
 * @param marginAfterInMinutes
 */
public TimePointFilter(LocalTime timePoint, int marginBeforeInMinutes, int marginAfterInMinutes) {
    this.marginBeforeInMinutes = marginBeforeInMinutes;
    this.marginAfterInMinutes = marginAfterInMinutes;
    startTime = timePoint.minus(marginBeforeInMinutes, ChronoUnit.MINUTES);
    endTime = timePoint.plus(marginAfterInMinutes, ChronoUnit.MINUTES);
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:17,代碼來源:TimePointFilter.java


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