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


Java LocalDate.minusDays方法代码示例

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


在下文中一共展示了LocalDate.minusDays方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: givenSomePast_someUpcoming_andSomeFarFutureEvents_suppliesOnlyUpcomingEvents

import java.time.LocalDate; //导入方法依赖的package包/类
@Test
public void givenSomePast_someUpcoming_andSomeFarFutureEvents_suppliesOnlyUpcomingEvents() throws Exception {
    LocalDate today = LocalDate.now();
    LocalDate yesterday = today.minusDays(1);
    LocalDate tomorrow = today.plusDays(1);
    LocalDate dayAfterTomorrow = today.plusDays(2);

    eventRepository.save(new Event("Today", yesterday));
    Event eventToday = eventRepository.save(new Event("Today", today));
    Event eventTomorrow = eventRepository.save(new Event("Today", tomorrow));
    Event eventDayAfterTomorrow = eventRepository.save(new Event("Today", dayAfterTomorrow));

    assertThat(
            new FetchUpcomingEvents(eventRepository, 1).perform(today, events1 -> events1),
            containsInAnyOrder(eventToday, eventTomorrow)
    );

    assertThat(
            new FetchUpcomingEvents(eventRepository, 2).perform(today, events -> events),
            containsInAnyOrder(eventToday, eventTomorrow, eventDayAfterTomorrow)
    );
}
 
开发者ID:pivotal,项目名称:spring-samples,代码行数:23,代码来源:FetchUpcomingEventsTest.java

示例2: getTaskCountForWorkbasketByDaysInPastAndState

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public long getTaskCountForWorkbasketByDaysInPastAndState(String workbasketId, long daysInPast,
    List<TaskState> states) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(
            "entry to getTaskCountForWorkbasketByDaysInPastAndState(workbasketId {}, daysInPast={}, states = {})",
            workbasketId, daysInPast, LoggerUtils.listToString(states));
    }
    long result = -1;
    try {
        taskanaEngineImpl.openConnection();
        LocalDate time = LocalDate.now();
        time = time.minusDays(daysInPast);
        Date fromDate = Date.valueOf(time);
        result = taskMonitorMapper.getTaskCountForWorkbasketByDaysInPastAndState(workbasketId, fromDate, states);
        return result;
    } finally {
        taskanaEngineImpl.returnConnection();
        LOGGER.debug("exit from getTaskCountForWorkbasketByDaysInPastAndState(). Returning result {} ", result);
    }
}
 
开发者ID:Taskana,项目名称:taskana,代码行数:22,代码来源:TaskMonitorServiceImpl.java

示例3: getTaskCountByWorkbasketAndDaysInPastAndState

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast,
    List<TaskState> states) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("entry to getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast = {}, states = {})",
            daysInPast, LoggerUtils.listToString(states));
    }
    List<DueWorkbasketCounter> result = null;
    try {
        taskanaEngineImpl.openConnection();
        LocalDate time = LocalDate.now();
        time = time.minusDays(daysInPast);
        Date fromDate = Date.valueOf(time);
        result = taskMonitorMapper.getTaskCountByWorkbasketIdAndDaysInPastAndState(fromDate, states);
        return result;
    } finally {
        taskanaEngineImpl.returnConnection();
        if (LOGGER.isDebugEnabled()) {
            int numberOfResultObjects = result == null ? 0 : result.size();
            LOGGER.debug(
                "exit from getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast,states). Returning {} resulting Objects: {} ",
                numberOfResultObjects, LoggerUtils.listToString(result));
        }
    }
}
 
开发者ID:Taskana,项目名称:taskana,代码行数:26,代码来源:TaskMonitorServiceImpl.java

示例4: getReservasEmAbertoNaSemana

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public List<ReservaEntity> getReservasEmAbertoNaSemana(LocalDate data) {
	ArrayList<ReservaEntity> resultado = new ArrayList<>();

	if (!data.getDayOfWeek().equals(DayOfWeek.MONDAY))
		data = data.minusDays(data.getDayOfWeek().getValue() - 1);
	do {
		resultado.addAll(getReservasEmAbertoNoDia(data));
		data = data.plusDays(1);
	} while (!data.getDayOfWeek().equals(DayOfWeek.SUNDAY));

	for (ReservaEntity reservaEntity : resultado) {
		System.out.println(reservaEntity.getDataSolicitacao() + " " + reservaEntity.getStatus());
	}

	return resultado;
}
 
开发者ID:dev-andremonteiro,项目名称:AlphaLab,代码行数:18,代码来源:MockReservaDAO.java

示例5: test_minusHours_one

import java.time.LocalDate; //导入方法依赖的package包/类
@Test
public void test_minusHours_one() {
    LocalDateTime t =TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = t.toLocalDate();

    for (int i = 0; i < 50; i++) {
        t = t.minusHours(1);

        if (i % 24 == 0) {
            d = d.minusDays(1);
        }

        assertEquals(t.toLocalDate(), d);
        assertEquals(t.getHour(), (((-i + 23) % 24) + 24) % 24);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TCKLocalDateTime.java

示例6: test_minusHours_fromZero

import java.time.LocalDate; //导入方法依赖的package包/类
@Test
public void test_minusHours_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().plusDays(2);
    LocalTime t = LocalTime.of(3, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.minusHours(i);
        t = t.minusHours(1);

        if (t.getHour() == 23) {
            d = d.minusDays(1);
        }

        assertEquals(dt.toLocalDate(), d, String.valueOf(i));
        assertEquals(dt.toLocalTime(), t);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:TCKLocalDateTime.java

示例7: test_minusHours_fromOne

import java.time.LocalDate; //导入方法依赖的package包/类
@Test
public void test_minusHours_fromOne() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0));
    LocalDate d = base.toLocalDate().plusDays(2);
    LocalTime t = LocalTime.of(4, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.minusHours(i);

        t = t.minusHours(1);

        if (t.getHour() == 23) {
            d = d.minusDays(1);
        }

        assertEquals(dt.toLocalDate(), d, String.valueOf(i));
        assertEquals(dt.toLocalTime(), t);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKLocalDateTime.java

示例8: testSplitLocalDate

import java.time.LocalDate; //导入方法依赖的package包/类
@Test(dataProvider = "directions")
public void testSplitLocalDate(boolean ascending) {
    final Period step = Period.ofDays(1);
    final LocalDate start = LocalDate.of(1990, 1, 1);
    final LocalDate end = ascending ? start.plusDays(10000) : start.minusDays(10000);
    final Range<LocalDate> range = Range.of(start, end, step);
    final List<Range<LocalDate>> segments = range.split(100);
    Assert.assertTrue(segments.size() > 1, "There are multiple segments");
    for (int i=1; i<segments.size(); ++i) {
        final Range<LocalDate> prior = segments.get(i-1);
        final Range<LocalDate> next = segments.get(i);
        Assert.assertEquals(prior.end(), next.start(), "Date connect as expect");
        if (i == 1) Assert.assertEquals(prior.start(), range.start(), "First segment start matches range start");
        if (i == segments.size()-1) {
            Assert.assertEquals(next.end(), range.end(), "Last segment end matches range end");
        }
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:19,代码来源:RangeSplitTests.java

示例9: localDate

import java.time.LocalDate; //导入方法依赖的package包/类
public static void localDate() {

        LocalDate now = LocalDate.now();
        LocalDate plus = now.plus(1, ChronoUnit.DAYS);
        LocalDate minus = now.minusDays(1);

        System.out.println(now); //2017-09-20
        System.out.println(plus); //2017-09-21
        System.out.println(minus); //2017-09-19

        LocalDate customDate = LocalDate.of(2017, Month.SEPTEMBER, 20);
        DayOfWeek dayOfWeek = customDate.getDayOfWeek();
        System.out.println(dayOfWeek); //WEDNESDAY 星期三

        DateTimeFormatter dateTimeFormatter = DateTimeFormatter
                .ofLocalizedDate(FormatStyle.MEDIUM)
                .withLocale(Locale.CHINA);
        LocalDate parse = LocalDate.parse("2017-09-20", dateTimeFormatter);
        System.out.println(parse); //2017-09-20
    }
 
开发者ID:daishicheng,项目名称:outcomes,代码行数:21,代码来源:Main.java

示例10: cleanUpSyncLog

import java.time.LocalDate; //导入方法依赖的package包/类
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
public void cleanUpSyncLog() {
    LocalDate today = LocalDate.now(ZoneId.systemDefault()) ;
    LocalDate startDate = today.minusDays(delay);
    long delayMillis = startDate.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();

    log.info("Deleting logs before " + startDate + " where epoch day = " + delayMillis);
    jongo.getCollection(SYNC_LOG).remove("{ epochDay: { $lte: # }}", delayMillis);
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:10,代码来源:SyncLogCleanUpService.java

示例11: lastOpeningDay

import java.time.LocalDate; //导入方法依赖的package包/类
/**
 * Returns last opening relative to passed date. If the mensa is open on that day, the date is returned
 * @param date to find last opening day for
 * @param mensa to check
 * @return last opening relative to passed date
 */
public LocalDate lastOpeningDay(LocalDate date, Mensa mensa) {
    LocalDate result = date;
    while (!isOpeningDay(result, mensa)) {
        result = result.minusDays(1);
    }
    return result;
}
 
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:14,代码来源:TimeUtils.java

示例12: getAtivosNaSemana

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public List<ReservaEntity> getAtivosNaSemana(LocalDate data) {
	ArrayList<ReservaEntity> resultado = new ArrayList<>();

	if (!data.getDayOfWeek().equals(DayOfWeek.MONDAY))
		data = data.minusDays(data.getDayOfWeek().getValue() - 1);
	do {
		resultado.addAll(getAtivosNoDia(data));
		data = data.plusDays(1);
	} while (!data.getDayOfWeek().equals(DayOfWeek.SUNDAY));

	return resultado;
}
 
开发者ID:dev-andremonteiro,项目名称:AlphaLab,代码行数:14,代码来源:MockReservaDAO.java

示例13: onCreateView

import java.time.LocalDate; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.chart_frag, container, false);

    // Set up timeline chart
    chart = view.findViewById(R.id.timeline);
    entries = new ArrayList<>();

    // Set up the x-axis
    XAxis xAxis = chart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

    formatter = DateTimeFormatter.ofPattern("MMM d");
    dates = new ArrayList<>();

    int numDays = 14;
    LocalDate today = LocalDate.now();
    minimumDate = today.minusDays(numDays);
    LocalDate currentDay = minimumDate;

    dateMap = new HashMap<>();

    for (int i = 0; i < numDays + 1; i++) {
        float index = (float) i;

        String dateString = currentDay.format(formatter);
        dates.add(dateString);
        dateMap.put(dateString, i);

        BarEntry barEntry = new BarEntry(index, new float[] { 0, 0, 0, 0 });
        entries.add(barEntry);

        currentDay = currentDay.plusDays(1);
    }

    xAxis.setValueFormatter(new MyXAxisValueFormatter(dates));
    xAxis.setLabelCount(numDays);
    xAxis.setGranularity(1f);
    xAxis.setLabelRotationAngle(45f);

    UserAccount currentUser = HabitUpApplication.getCurrentUser();

    // Get user events
    ArrayList<HabitEvent> eventList = currentUser.getEventList().getEvents();

    for (HabitEvent event : eventList) {
        if (withinDateRange(event.getCompletedate(), minimumDate)) {
            addChartEntry(event);
        }
    }

    set = new BarDataSet(entries, "");
    int red = Color.parseColor(Attributes.getColour("Physical"));
    int purple = Color.parseColor(Attributes.getColour("Mental"));
    int green = Color.parseColor(Attributes.getColour("Discipline"));
    int blue = Color.parseColor(Attributes.getColour("Social"));
    int[] colors = {red, purple, green, blue};
    set.setColors(colors);
    set.setStackLabels(new String[]{"Physical", "Mental", "Discipline", "Social"});
    set.setDrawValues(false);

    BarData data = new BarData(set);
    data.setBarWidth(0.6f);

    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setValueFormatter(new MyYAxisValueFormatter());
    leftAxis.setGranularity(1f);
    leftAxis.setAxisMinimum(0f);
    chart.getAxisRight().setEnabled(false);

    chart.setData(data);
    chart.setFitBars(true);
    chart.getXAxis().setDrawGridLines(false);
    chart.getAxisLeft().setDrawGridLines(false);
    chart.getDescription().setEnabled(false);
    animateChart();
    chart.invalidate();

    return view;
}
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:82,代码来源:ChartFragment.java

示例14: getTaskCountByWorkbasketAndDaysInPastAndState

import java.time.LocalDate; //导入方法依赖的package包/类
@RequestMapping(value = "/taskcountByWorkbasketDaysAndState")
public ResponseEntity<?> getTaskCountByWorkbasketAndDaysInPastAndState(
    @RequestParam(value = "daysInPast") Long daysInPast,
    @RequestParam(value = "states") List<TaskState> states) {
    try {
        WorkbasketCounterDto WorkbasketCounterDto = new WorkbasketCounterDto();

        LocalDate date = LocalDate.now();
        date = date.minusDays(daysInPast);
        List<String> dates = new ArrayList<>();

        for (int i = 0; i < (daysInPast * 2 + 1); i++) {
            dates.add(date.format(new DateTimeFormatterBuilder().appendPattern("dd.MM.yyyy").toFormatter()));
            date = date.plusDays(1);
        }
        WorkbasketCounterDto.setDates(dates);

        List<WorkbasketCounterDataDto> data = new ArrayList<>();

        for (WorkbasketSummary workbasket : workbasketService.getWorkbaskets()) {
            WorkbasketCounterDataDto counterDto = new WorkbasketCounterDataDto();
            counterDto.setLabel(workbasket.getName());
            List<Integer> zeroData = new ArrayList<>();
            for (int i = 0; i < dates.size(); i++) {
                zeroData.add(0);
            }
            counterDto.setData(zeroData);
            data.add(counterDto);
        }

        List<DueWorkbasketCounter> dwcList = taskMonitorService.getTaskCountByWorkbasketAndDaysInPastAndState(
            daysInPast,
            states);

        for (DueWorkbasketCounter item : dwcList) {
            String formattedDate = item.getDue()
                .toLocalDate()
                .format(new DateTimeFormatterBuilder().appendPattern("dd.MM.yyyy").toFormatter());
            for (int i = 0; i < dates.size(); i++) {
                if (formattedDate.equalsIgnoreCase(dates.get(i))) {
                    for (int j = 0; j < data.size(); j++) {
                        if (data.get(j).getLabel().equalsIgnoreCase(
                            workbasketService.getWorkbasket(item.getWorkbasketId()).getName())) {
                            data.get(j).getData().set(i, (int) item.getTaskCounter());
                        }
                    }
                }
            }
        }

        WorkbasketCounterDto.setData(data);

        return ResponseEntity.status(HttpStatus.OK).body(WorkbasketCounterDto);
    } catch (Exception e) {
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
 
开发者ID:Taskana,项目名称:taskana,代码行数:58,代码来源:MonitorController.java

示例15: createControl

import java.time.LocalDate; //导入方法依赖的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


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