当前位置: 首页>>代码示例>>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;未经允许,请勿转载。