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


Java YearMonth.atDay方法代碼示例

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


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

示例1: createEntries

import java.time.YearMonth; //導入方法依賴的package包/類
private void createEntries(YearMonth month) {
    for (int i = 1; i < 28; i++) {

        LocalDate date = month.atDay(i);

        for (int j = 0; j < (int) (Math.random() * 7); j++) {
            Entry<?> entry = new Entry<>();
            entry.changeStartDate(date);
            entry.changeEndDate(date);

            entry.setTitle("Entry " + (j + 1));

            int hour = (int) (Math.random() * 23);
            int durationInHours = Math.min(24 - hour,
                    (int) (Math.random() * 4));

            LocalTime startTime = LocalTime.of(hour, 0);
            LocalTime endTime = startTime.plusHours(durationInHours);

            entry.changeStartTime(startTime);
            entry.changeEndTime(endTime);

            if (Math.random() < .3) {
                entry.setFullDay(true);
            }

            entry.setCalendar(this);
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:31,代碼來源:HelloYearMonthView.java

示例2: HelloCalendar

import java.time.YearMonth; //導入方法依賴的package包/類
public HelloCalendar() {
    for (Month month : Month.values()) {

        YearMonth yearMonth = YearMonth.of(LocalDate.now().getYear(), month);

        for (int i = 1; i < 28; i++) {

            LocalDate date = yearMonth.atDay(i);

            for (int j = 0; j < (int) (Math.random() * 7); j++) {
                Entry<?> entry = new Entry<>();
                entry.changeStartDate(date);
                entry.changeEndDate(date);

                entry.setTitle("Entry " + (j + 1));

                int hour = (int) (Math.random() * 23);
                int durationInHours = Math.min(24 - hour,
                        (int) (Math.random() * 4));

                LocalTime startTime = LocalTime.of(hour, 0);
                LocalTime endTime = startTime
                        .plusHours(durationInHours);

                entry.changeStartTime(startTime);
                entry.changeEndTime(endTime);

                if (Math.random() < .3) {
                    entry.setFullDay(true);
                }

                entry.setCalendar(this);
            }
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:37,代碼來源:HelloCalendarView.java

示例3: createEntries

import java.time.YearMonth; //導入方法依賴的package包/類
private void createEntries(YearMonth month) {
    for (int i = 1; i < 28; i++) {

        LocalDate date = month.atDay(i);

        for (int j = 0; j < (int) (Math.random() * 2); j++) {
            Entry<?> entry = new Entry<>();

            entry.setTitle("Entry " + (j + 1));

            LocalDate startDate = date;
            LocalDate endDate = startDate.plusDays((int) (Math.random() * 4));

            int hour = (int) (Math.random() * 23);
            int durationInHours = Math.min(23 - hour, (int) (Math.random() * 4));

            LocalTime startTime = LocalTime.of(hour, 0);
            LocalTime endTime = startTime.plusHours(durationInHours);

            entry.setInterval(startDate, startTime, endDate, endTime);

            if (Math.random() < .3) {
                entry.setFullDay(true);
            }

            entry.setCalendar(this);
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:30,代碼來源:HelloMonthView.java

示例4: createEntries

import java.time.YearMonth; //導入方法依賴的package包/類
private void createEntries(YearMonth month) {
    for (int i = 1; i < 28; i++) {

        LocalDate date = month.atDay(i);

        for (int j = 0; j < (int) (Math.random() * 7); j++) {
            Entry<?> entry = new Entry<>();

            entry.setTitle("Entry " + (j + 1));

            int hour = (int) (Math.random() * 22);
            int durationInHours = Math.min(24 - hour,
                    (int) (Math.random() * 4));

            LocalTime startTime = LocalTime.of(hour, 0);
            LocalTime endTime = startTime.plusHours(durationInHours);

            entry.setInterval(date, startTime, date.plusDays((int) (Math.random() * 4)), endTime);

            if (Math.random() < .3) {
                entry.setFullDay(true);
            }

            entry.setCalendar(this);
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:28,代碼來源:HelloMonthPage.java

示例5: isVisibleDate

import java.time.YearMonth; //導入方法依賴的package包/類
/**
 * Determines if the given date is currently showing is part of the view. This
 * method uses the extended start and end months.
 *
 * @param date the date to check for visibility
 * @return true if the date is within the time range of the view
 * @see #getExtendedStartMonth()
 * @see #getExtendedEndMonth()
 */
public final boolean isVisibleDate(LocalDate date) {
    if (date != null) {
        YearMonth extendedStart = getExtendedStartMonth();
        YearMonth extendedEnd = getExtendedEndMonth();

        LocalDate startDate = extendedStart.atDay(1);
        LocalDate endDate = extendedEnd.atEndOfMonth();

        if ((date.equals(startDate) || date.isAfter(startDate)) && (date.equals(endDate) || date.isBefore(endDate))) {
            return true;
        }
    }
    return false;
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:24,代碼來源:MonthSheetView.java

示例6: test_atDay

import java.time.YearMonth; //導入方法依賴的package包/類
@Test(dataProvider="atDay")
public void test_atDay(YearMonth test, int day, LocalDate expected) {
    if (expected != null) {
        assertEquals(test.atDay(day), expected);
    } else {
        try {
            test.atDay(day);
            fail();
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:TCKYearMonth.java

示例7: buildCells

import java.time.YearMonth; //導入方法依賴的package包/類
private void buildCells(YearMonth yearMonth, int colIndex) {
    List<Node> cells = new ArrayList<>();
    Node header = buildHeaderCell(yearMonth);
    header.getStyleClass().add("month-header");

    cells.add(header);

    LocalDate start = yearMonth.atDay(1);
    LocalDate end = yearMonth.atEndOfMonth();

    if (getSkinnable().getWeekDayLayout() == WeekDayLayoutStrategy.ALIGNED) {
        DayOfWeek firstDayOfWeek = getSkinnable().getFirstDayOfWeek();
        DayOfWeek startDayOfWeek = start.getDayOfWeek();
        int distanceDays = Math.abs(firstDayOfWeek.getValue() - startDayOfWeek.getValue());

        while (distanceDays-- > 0) {
            cells.add(buildCell(null));
        }
    }

    while (start.isBefore(end) || start.isEqual(end)) {
        cells.add(buildCell(start));
        start = start.plusDays(1);
    }

    buildEmptyCellBottom(cells);

    final YearMonth extendedStart = getSkinnable().getExtendedStartMonth();
    final YearMonth extendedEnd = getSkinnable().getExtendedEndMonth();

    cells.forEach(cell -> {
        if (extendedStart.equals(yearMonth)) {
            cell.getStyleClass().add("first-month");
        } else if (extendedEnd.equals(yearMonth)) {
            cell.getStyleClass().add("last-month");
        } else {
            cell.getStyleClass().add("middle-month");
        }
    });

    for (int i = 0; i < cells.size(); i++) {
        Node node = cells.get(i);
        grid.add(node, colIndex, i + 1);

        if (node instanceof DateCell) {

            final Position position = new Position(colIndex, i);
            final DateCell dateCell = (DateCell) node;
            final LocalDate date = dateCell.getDate();

            cellMap.put(date, dateCell);
            positionToDateCellMap.put(position, dateCell);
            dateToPositionMap.put(date, position);
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:57,代碼來源:MonthSheetViewSkin.java


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