当前位置: 首页>>代码示例>>Java>>正文


Java LocalTime.plus方法代码示例

本文整理汇总了Java中java.time.LocalTime.plus方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.plus方法的具体用法?Java LocalTime.plus怎么用?Java LocalTime.plus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.plus方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: doTimeMath

import java.time.LocalTime; //导入方法依赖的package包/类
private DateCalculatorResult doTimeMath(final OperatorToken operatorToken, final TimeToken startTimeToken, final Queue<Token> tokens) {
    int negate = operatorToken.isAddition() ? 1 : -1;
    LocalTime result = startTimeToken.getValue();

    while (!tokens.isEmpty()) {
        validateToken(tokens.peek(), IntegerToken.class);
        int amount = ((IntegerToken) tokens.poll()).getValue() * negate;
        validateToken(tokens.peek(), UnitOfMeasureToken.class);
        result = result.plus(amount, ((UnitOfMeasureToken) tokens.poll()).getValue());
    }
    return new DateCalculatorResult(result);
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:13,代码来源:DateCalculator.java

示例4: 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

示例5: 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

示例6: createControl

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
protected DateControl createControl() {
    CalendarSource source = new CalendarSource();
    source.setName("Demo Source");

    Calendar[] calendar = new Calendar[7];
    for (int i = 0; i < 7; i++) {
        calendar[i] = new Calendar("Calendar " + i);
        calendar[i].setStyle(Calendar.Style.getStyle(i));
    }

    for (int i = 0; i < 1000; i++) {
        Entry<String> entry = new Entry<>("Entry " + i);
        LocalDate date = LocalDate.now();
        if (Math.random() < .5) {
            date = date.minusDays((long) (Math.random() * 365));
        } else {
            date = date.plusDays((long) (Math.random() * 365));
        }

        LocalTime start = LocalTime.of((int) (Math.random() * 20), (int) (Math.random() * 30));
        Duration duration = Duration.ofHours((int) (Math.random() * 8));
        LocalTime end = start.plus(duration);
        if (end.isBefore(start)) {
            end = LocalTime.MAX;
        }

        entry.changeStartDate(date);
        entry.changeEndDate(date);
        entry.changeStartTime(start);
        entry.changeEndTime(end);

        if (Math.random() > .9) {
            entry.setFullDay(true);
        }

        entry.setCalendar(calendar[(int) (Math.random() * 7)]);
    }

    source.getCalendars().addAll(calendar);

    monthView = new MonthSheetView();
    monthView.getCalendarSources().add(source);
    monthView.setCellFactory(param -> new MonthSheetView.DetailedDateCell(param.getView(), param.getDate()));

    return monthView;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:48,代码来源:HelloMonthSheetView.java

示例7: timeRangeFormat

import java.time.LocalTime; //导入方法依赖的package包/类
private String timeRangeFormat(LocalTime timePart) {
    LocalTime timePart2 = timePart.plus(30, ChronoUnit.MINUTES);

    return timePart.format(dtf) + " - " + timePart2.format(dtf);
}
 
开发者ID:ericywl,项目名称:InfoSys-1D,代码行数:6,代码来源:WeekCalendarServiceImpl.java

示例8: 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.plus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。