本文整理汇总了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()));
}
}
示例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()));
}
}