本文整理匯總了Java中org.joda.time.LocalDate.plusDays方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalDate.plusDays方法的具體用法?Java LocalDate.plusDays怎麽用?Java LocalDate.plusDays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.LocalDate
的用法示例。
在下文中一共展示了LocalDate.plusDays方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dailyMenusMonthlyGet
import org.joda.time.LocalDate; //導入方法依賴的package包/類
/**
* @return a list to the chef, of Daily Menus of the current month
*/
@PreAuthorize("hasAuthority('chef')")
public List<DailyMenuChef> dailyMenusMonthlyGet()
{
LocalDate today = LocalDate.now();
LocalDate startOfMonth = today.dayOfMonth().withMinimumValue();
int daysOfMonth = today.dayOfMonth().withMaximumValue().getDayOfMonth();
List<DailyMenuChef> monthlyMenu = new ArrayList<>();
for (int i = 0; i < daysOfMonth; i++)
{
if (getDailyMenuChef(startOfMonth).getDate() != null)
monthlyMenu.add(getDailyMenuChef(startOfMonth));
startOfMonth = startOfMonth.plusDays(1);
}
return monthlyMenu;
}
示例2: dailyMenusMonthlyMonthyearGet
import org.joda.time.LocalDate; //導入方法依賴的package包/類
/**
* @return a list to the chef, of Daily Menus of month & year he wants
*/
@PreAuthorize("hasAuthority('chef')")
public List<DailyMenuChef> dailyMenusMonthlyMonthyearGet(String monthyear) throws ApiException
{
String patternString = "^\\d{2}-\\d{4}$";
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(patternString);
Matcher matcher = pattern.matcher(monthyear);
if (matcher.matches())
{
LocalDate monthYearDate = new LocalDate().withYear(Integer.parseInt(monthyear.substring(3, 7))).withMonthOfYear(Integer.parseInt(monthyear.substring(0, 2)));
LocalDate startOfMonth = monthYearDate.dayOfMonth().withMinimumValue();
int daysOfMonth = monthYearDate.dayOfMonth().withMaximumValue().getDayOfMonth();
List<DailyMenuChef> monthlyMenu = new ArrayList<>();
for (int i = 0; i < daysOfMonth; i++)
{
if (getDailyMenuChef(startOfMonth).getDate() != null)
monthlyMenu.add(getDailyMenuChef(startOfMonth));
startOfMonth = startOfMonth.plusDays(1);
}
return monthlyMenu;
}
else
throw new ApiException(400, "Invalid date");
}
示例3: createPlannedDate
import org.joda.time.LocalDate; //導入方法依賴的package包/類
private Date createPlannedDate(String type, Date d) {
LocalDate lo = LocalDate.fromDateFields(d);
switch (type) {
case "Daily":
lo = lo.plusDays(1);
break;
case "Weekly":
lo = lo.plusWeeks(1);
break;
case "Monthly":
lo = lo.plusMonths(1);
break;
case "Yearly":
lo = lo.plusYears(1);
break;
}
return lo.toDate();
}
示例4: sendAutoOrderSummary
import org.joda.time.LocalDate; //導入方法依賴的package包/類
private void sendAutoOrderSummary(){
System.out.println("RUN TASK SCHEDULE: " + LocalDateTime.now());
//Get deadline days
Settings settings = settingsRepo.findById(1);
int deadlinedays = settings.getDeadlineDays();
LocalDate day = new LocalDate();
if(this.holidaysRepo.findByIdHoliday(day) != null){
return;
}
LocalDate initDate = (day).plusDays(deadlinedays);
// while (this.holidaysRepo.findByIdHoliday(initDate) != null) {
// initDate = initDate.plusDays(1);
// }
LocalDate maxCheckdate = (initDate).plusDays(deadlinedays);
while (this.holidaysRepo.findByIdHoliday(maxCheckdate) != null) {
maxCheckdate = maxCheckdate.plusDays(1);
}
int checkDays = Days.daysBetween((new LocalDate()), maxCheckdate).getDays() + deadlinedays;
for (int i = 0; i <= checkDays; i++) { //newDeadlineDays
LocalDate dailyMenuDate = initDate.plusDays(i);
// if old deadline not passed and new deadline passed and dailyMenu not null, send report email
if (menusService.deadlinePassed(dailyMenuDate) && dailyMenuRepo.findByDate(dailyMenuDate) != null) { //
//System.out.println(">>>>>>>>>>>>>sending email, date: " + dailyMenuDate);
eService.sendOrderSummary(dailyMenuDate);
}
}
}
示例5: replaceOneString
import org.joda.time.LocalDate; //導入方法依賴的package包/類
@Override
public String replaceOneString(String body, Request request) {
Matcher dateMatcher = DATE.matcher(body);
dateMatcher.find();
String match = dateMatcher.group();
Map<String, String> query = getQueryFromUri(match);
LocalDate date = new LocalDate();
if(query.containsKey(OFFSET_PARAMETER)) {
date = date.plusDays(Integer.parseInt(query.get(OFFSET_PARAMETER)));
}
body = dateMatcher.replaceFirst(date.toString());
return body;
}
示例6: getSlots
import org.joda.time.LocalDate; //導入方法依賴的package包/類
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result getSlots(Long examId, Long roomId, String day, Collection<Integer> aids) {
User user = getLoggedUser();
Exam exam = getEnrolledExam(examId, user);
if (exam == null) {
return forbidden("sitnet_error_enrolment_not_found");
}
ExamRoom room = Ebean.find(ExamRoom.class, roomId);
if (room == null) {
return forbidden(String.format("No room with id: (%d)", roomId));
}
Collection<TimeSlot> slots = new ArrayList<>();
if (!room.getOutOfService() && !room.getState().equals(ExamRoom.State.INACTIVE.toString()) &&
isRoomAccessibilitySatisfied(room, aids) && exam.getDuration() != null) {
LocalDate searchDate;
try {
searchDate = parseSearchDate(day, exam, room);
} catch (NotFoundException e) {
return notFound();
}
// users reservations starting from now
List<Reservation> reservations = Ebean.find(Reservation.class)
.fetch("enrolment.exam")
.where()
.eq("user", user)
.gt("startAt", searchDate.toDate())
.findList();
// Resolve eligible machines based on software and accessibility requirements
List<ExamMachine> machines = getEligibleMachines(room, aids, exam);
LocalDate endOfSearch = getEndSearchDate(exam, searchDate);
while (!searchDate.isAfter(endOfSearch)) {
Set<TimeSlot> timeSlots = getExamSlots(user, room, exam, searchDate, reservations, machines);
if (!timeSlots.isEmpty()) {
slots.addAll(timeSlots);
}
searchDate = searchDate.plusDays(1);
}
}
return ok(Json.toJson(slots));
}
示例7: provideSlots
import org.joda.time.LocalDate; //導入方法依賴的package包/類
@SubjectNotPresent
public Result provideSlots(Optional<String> roomId, Optional<String> date, Optional<String> start, Optional<String> end,
Optional<Integer> duration) {
if (roomId.isPresent() && date.isPresent() && start.isPresent() && end.isPresent() && duration.isPresent()) {
ExamRoom room = Ebean.find(ExamRoom.class).where().eq("externalRef", roomId.get()).findUnique();
if (room == null) {
return forbidden(String.format("No room with ref: (%s)", roomId.get()));
}
Collection<TimeSlot> slots = new ArrayList<>();
if (!room.getOutOfService() && !room.getState().equals(ExamRoom.State.INACTIVE.toString())) {
LocalDate searchDate;
try {
searchDate = parseSearchDate(date.get(), start.get(), end.get(), room);
} catch (NotFoundException e) {
return notFound();
}
List<ExamMachine> machines = Ebean.find(ExamMachine.class)
.where()
.eq("room.id", room.getId())
.ne("outOfService", true)
.ne("archived", true)
.findList();
LocalDate endOfSearch = getEndSearchDate(end.get(), searchDate);
while (!searchDate.isAfter(endOfSearch)) {
Set<TimeSlot> timeSlots = getExamSlots(room, duration.get(), searchDate, machines);
if (!timeSlots.isEmpty()) {
slots.addAll(timeSlots);
}
searchDate = searchDate.plusDays(1);
}
}
return ok(Json.toJson(slots));
} else {
return badRequest();
}
}
示例8: onJournalUpdated
import org.joda.time.LocalDate; //導入方法依賴的package包/類
@Override
public void onJournalUpdated(List<Trip> trips) {
tripDays.clear();
for (Trip t : trips) {
LocalDate d = DateTime.parse(t.getStartDate()).toLocalDate();
LocalDate endDate = DateTime.parse(t.getEndDate()).toLocalDate();
while (!d.isAfter(endDate)) {
tripDays.add(d);
d = d.plusDays(1);
}
}
monthly.invalidateDecorators();
}
示例9: ordersMonthlyMonthyearGet
import org.joda.time.LocalDate; //導入方法依賴的package包/類
public List<DailyMenuOrder> ordersMonthlyMonthyearGet(String monthyear) throws ApiException {
//Decode & Validate month request
String patternString = "^(\\d{2})-(\\d{4})$";
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher(monthyear);
if (!matcher.matches()) {
throw new ApiException(400, "Bad request of month-year format");
}
//Build list
List<DailyMenuOrder> dailyMenuOrders = new ArrayList<>();
//LocalDate monthYearDate = new LocalDate().withYear(Integer.parseInt(monthyear.substring(3, 7))).withMonthOfYear(Integer.parseInt(monthyear.substring(0, 2)));
LocalDate monthYearDate = new LocalDate().withYear(Integer.parseInt(matcher.group(2))).withMonthOfYear(Integer.parseInt(matcher.group(1)));
LocalDate startOfMonth = monthYearDate.dayOfMonth().withMinimumValue();
int daysOfMonth = monthYearDate.dayOfMonth().withMaximumValue().getDayOfMonth();
// for each day of month
for (int i=0; i<daysOfMonth; i++) {
com.jrtechnologies.yum.data.entity.DailyMenu dailyMenuEntity = dailyMenuRep.findByDate(startOfMonth);
if(dailyMenuEntity!=null && dailyMenuEntity.hasOrders()){
// DailymenuOrder-->OrderItems
List<OrderItem> orderItemList = new ArrayList<OrderItem>();
DailyMenuOrder dailyOrder = new DailyMenuOrder();
dailyOrder.setDailyMenuDate(dailyMenuEntity.getDate());
dailyOrder.setDailyMenuId(dailyMenuEntity.getId());
//get summary of daily orders in a list of orders, food id + quantity
orderItemList = getOrderItemList(dailyMenuEntity, ALL_USERS);
dailyOrder.setOrderItems(orderItemList);
dailyMenuOrders.add(dailyOrder);
}
startOfMonth = startOfMonth.plusDays(1);
}
return dailyMenuOrders;
}