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


Java ZonedDateTime.get方法代碼示例

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


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

示例1: forward

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Override
public void forward(CalendarComponentEvents.ForwardEvent event) {

    int firstDay = event.getComponent().getFirstVisibleDayOfWeek();
    int lastDay = event.getComponent().getLastVisibleDayOfWeek();

    ZonedDateTime start = event.getComponent().getStartDate();
    ZonedDateTime end = event.getComponent().getEndDate();

    long durationInDays;

    // for week view durationInDays = 7, for day view durationInDays = 1
    if (event.getComponent().isDayMode()) { // day view
        durationInDays = 1;
    } else if (event.getComponent().isWeeklyMode()) {
        durationInDays = 7;
    } else {
        durationInDays = Duration.between(start, end).toDays() +1;
    }

    start = start.plus(durationInDays, ChronoUnit.DAYS);
    end = end.plus(durationInDays, ChronoUnit.DAYS);

    if (event.getComponent().isDayMode()) { // day view

        int dayOfWeek = start.get(ChronoField.DAY_OF_WEEK);

        ZonedDateTime newDate = start;
        while (!(firstDay <= dayOfWeek && dayOfWeek <= lastDay)) {

            newDate = newDate.plus(1, ChronoUnit.DAYS);

            dayOfWeek = start.get(ChronoField.DAY_OF_WEEK);
        }

        setDates(event, newDate, newDate);

        return;
    }

    if (durationInDays < 28) {
        setDates(event, start, end);
    } else {
        // go 7 days forth and get the first day from month
        setDates(event, start.with(firstDayOfMonth()), end.plus(7, ChronoUnit.DAYS).with(firstDayOfMonth()));
    }

}
 
開發者ID:blackbluegl,項目名稱:calendar-component,代碼行數:49,代碼來源:BasicForwardHandler.java

示例2: backward

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Override
public void backward(CalendarComponentEvents.BackwardEvent event) {

    int firstDay = event.getComponent().getFirstVisibleDayOfWeek();
    int lastDay = event.getComponent().getLastVisibleDayOfWeek();

    ZonedDateTime start = event.getComponent().getStartDate();
    ZonedDateTime end = event.getComponent().getEndDate();

    long durationInDays;

    // for week view durationInDays = 7, for day view durationInDays = 1
    if (event.getComponent().isDayMode()) { // day view
        durationInDays = 1;
    } else if (event.getComponent().isWeeklyMode()) {
        durationInDays = 7;
    } else {
        durationInDays = Duration.between(start, end).toDays() +1;
    }

    start = start.minus(durationInDays, ChronoUnit.DAYS);
    end = end.minus(durationInDays, ChronoUnit.DAYS);

    if (event.getComponent().isDayMode()) { // day view

        int dayOfWeek = start.get(ChronoField.DAY_OF_WEEK);

        ZonedDateTime newDate = start;
        while (!(firstDay <= dayOfWeek && dayOfWeek <= lastDay)) {

            newDate = newDate.minus(1, ChronoUnit.DAYS);

            dayOfWeek = start.get(ChronoField.DAY_OF_WEEK);
        }

        setDates(event, newDate, newDate);

        return;

    }

    if (durationInDays < 28) {
        setDates(event, start, end);
    } else {
        // go 7 days before and get the last day from month
        setDates(event, start.minus(7, ChronoUnit.DAYS).with(lastDayOfMonth()), end.with(lastDayOfMonth()));
    }
}
 
開發者ID:blackbluegl,項目名稱:calendar-component,代碼行數:49,代碼來源:BasicBackwardHandler.java


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