本文整理匯總了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()));
}
}