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


Java LocalDate.plusDays方法代碼示例

本文整理匯總了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;
}
 
開發者ID:jrtechnologies,項目名稱:yum,代碼行數:20,代碼來源:DailyMenuService.java

示例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");
}
 
開發者ID:jrtechnologies,項目名稱:yum,代碼行數:27,代碼來源:DailyMenuService.java

示例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();
}
 
開發者ID:alewin,項目名稱:moneytracking,代碼行數:19,代碼來源:MoneyReminder.java

示例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);
            }
        }

    }
 
開發者ID:jrtechnologies,項目名稱:yum,代碼行數:37,代碼來源:ReportEmail.java

示例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;
}
 
開發者ID:politedog,項目名稱:mock-interceptor,代碼行數:14,代碼來源:AbstractMockedApiInterceptor.java

示例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));
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:41,代碼來源:CalendarController.java

示例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();
    }
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:37,代碼來源:ExternalCalendarController.java

示例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();
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:14,代碼來源:MonthlyFragment.java

示例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;
    
}
 
開發者ID:jrtechnologies,項目名稱:yum,代碼行數:47,代碼來源:ChefOrdersService.java


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