Example usage for org.joda.time LocalDateTime plusDays

List of usage examples for org.joda.time LocalDateTime plusDays

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime plusDays.

Prototype

public LocalDateTime plusDays(int days) 

Source Link

Document

Returns a copy of this datetime plus the specified number of days.

Usage

From source file:org.kuali.kpme.tklm.time.util.TkTimeBlockAggregate.java

License:Educational Community License

/**
 * When consuming these weeks, you must be aware that you could be on a
 * virtual day, ie noon to noon schedule and have your FLSA time start
 * before the virtual day start,/*from  w  w w.  j ava 2  s .c  o m*/
 * but still have a full 7 days for your week.
  *
  * @param zone The TimeZone to use when constructing this relative sorting.
 */
public List<FlsaWeek> getFlsaWeeks(DateTimeZone zone) {
    int flsaDayConstant = payCalendar.getFlsaBeginDayConstant();
    Time flsaBeginTime = payCalendar.getFlsaBeginTime();

    // We can use these to build our interval, we have to make sure we
    // place them on the proper day when we construct it.
    LocalTime flsaBeginLocalTime = LocalTime.fromDateFields(flsaBeginTime);

    // Defines both the start date and the start virtual time.
    // We will add 1 day to this to move over all days.
    //
    // FLSA time is set.  This is an FLSA start date.
    LocalDateTime startLDT = payCalendarEntry.getBeginPeriodLocalDateTime();

    List<FlsaWeek> flsaWeeks = new ArrayList<FlsaWeek>();
    List<TimeBlock> flattenedTimeBlocks = getFlattenedTimeBlockList();
    List<LeaveBlock> flattenedLeaveBlocks = getFlattenedLeaveBlockList();
    FlsaWeek currentWeek = new FlsaWeek(flsaDayConstant, flsaBeginLocalTime,
            payCalendarEntry.getBeginPeriodFullDateTime().toLocalTime());
    FlsaDay flsaDay = new FlsaDay(startLDT, flattenedTimeBlocks, flattenedLeaveBlocks, zone);
    currentWeek.addFlsaDay(flsaDay);
    flsaWeeks.add(currentWeek);

    for (int i = 1; i < dayTimeBlockList.size(); i++) {
        LocalDateTime currentDate = startLDT.plusDays(i);
        flsaDay = new FlsaDay(currentDate, flattenedTimeBlocks, flattenedLeaveBlocks, zone);

        if (currentDate.getDayOfWeek() == flsaDayConstant) {
            currentWeek = new FlsaWeek(flsaDayConstant, flsaBeginLocalTime, flsaBeginLocalTime);
            flsaWeeks.add(currentWeek);
        }

        currentWeek.addFlsaDay(flsaDay);
    }

    return flsaWeeks;
}

From source file:view.EmprestimoAddInternalFrame.java

private void salvarEmprestimoBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarEmprestimoBtnActionPerformed
    if (model.getSize() > 0 && !selecionados.isEmpty()) {
        if (pessoaBox.getSelectedIndex() > -1) {
            salvarEmprestimoBtn.setEnabled(false);
            String codigo_pessoa = pessoaBox.getSelectedItem().toString();
            Pessoa alugador = new Pessoa(0, 0, null, null, null);
            for (Pessoa p : pessoas) {
                if (codigo_pessoa.equals(p.getCodigo())) {
                    alugador = p;/*from w  ww  .j a v a  2s .  c  o  m*/
                    pessoas.remove(p);
                    break;
                }
            }
            int plus_days = Integer.valueOf(diaSpinner.getValue().toString());
            LocalDateTime inicio = new LocalDateTime(System.currentTimeMillis());
            LocalDateTime fim = inicio.plusDays(plus_days);
            if (EmprestimoController.Salvar(alugador.getId_pessoa(), selecionados, inicio, fim)) {
                Runnable t1 = () -> {
                    if (eif != null)
                        eif.updateEmprestimoTable("");
                    if (lif != null)
                        lif.updateExemplarTableModel("");
                    exemplares.removeAll(selecionados);
                    updateLivroBox();
                    updatePessoaBox();
                    selecionados.clear();
                    model = new DefaultListModel();
                    diaSpinner.setValue(prazo_default);
                    livroList.setModel(model);
                };
                new Thread(t1).start();

                salvarEmprestimoBtn.setEnabled(true);
                //pessoaBox.setSelectedIndex(0);
                pessoaLabel.setText("Cdigo, nome, turma:");
                buscaPessoaField.setText("");
                buscaLivroField.setText("");
                //livroBox.setSelectedIndex(0);
                codigoLabel.setText("Selecione o Cdigo:");
                escolhePessoaBtn.setEnabled(true);
                pessoaBox.setEnabled(true);
            } else
                salvarEmprestimoBtn.setEnabled(true);
        } else
            JOptionPane.showMessageDialog(null, "Selecione uma pessoa. ", "Ateno",
                    JOptionPane.WARNING_MESSAGE);
    } else
        JOptionPane.showMessageDialog(null, "Selecione ao menos um exemplar. ", "Ateno",
                JOptionPane.WARNING_MESSAGE);

}

From source file:view.popups.timePeriod.AddTimePeriodPopup.java

/**
 * Henter timeperiods, og tager hjde for hvad der er valgt i forbindelse
 * med om den oprettede regel skal gentages eller ej.
 * @return en liste af tidsperioder./*from   w w w .  j a  va 2  s .c om*/
 */
private ArrayList<TimePeriod> getRepeatedTimeInvestments() {
    LocalDateTime startTime = cStart.getValue();
    LocalDateTime endTime = cEnd.getValue();
    Room room = cRoom.getValue();
    ObservableList<Employee> employees = lEmp.getItems();
    ArrayList<TimePeriod> timePeriods = new ArrayList<>();

    for (int i = 0; i < employees.size(); i++) {
        Employee employee = employees.get(i);
        if (!cEmp.isDisabled()) {
            if (rbRepeat.isSelected()) {
                if (repeat > 0) {
                    for (int j = 0; j < repeat; j++) {
                        TimePeriod tpToAdd = new TimePeriod(startTime, endTime, min, max, room, employee);
                        int daysBetween = Days.daysBetween(startTime, endTime).getDays();
                        startTime = endTime.plusDays(1);
                        endTime = startTime.plusDays(daysBetween);

                        timePeriods.add(tpToAdd);
                    }
                }

            } else {
                TimePeriod tpToAdd = new TimePeriod(startTime, endTime, min, max, room, employee);

                timePeriods.add(tpToAdd);
            }
        } else {
            break;
        }
    }
    return timePeriods;
}

From source file:view.schema.AssignedAllRoomsRow.java

public AssignedAllRoomsRow(String shiftName, LocalDateTime startTime, ArrayList<TimeInvestment> shifts,
        int startHour, int startMinute, int periodLengthHour, int periodLengthMinute) {

    this.shifts = shifts;
    this.startTime = startTime;
    shiftTypeLabel = new RoomTile(shiftName);

    this.setOrientation(Orientation.HORIZONTAL);

    this.getChildren().add(shiftTypeLabel);

    //Tilfj vagter til dagene p ugen. i0 = mandag, i4 = fredag.
    for (int i = 0; i < 5; i++) {
        LocalDateTime date = startTime.plusDays(i);
        date = date.withField(DateTimeFieldType.hourOfDay(), startHour);
        date = date.withField(DateTimeFieldType.minuteOfHour(), startMinute);
        //Nulstil sekunder og millisekunder (vigtigt).
        date = date.withSecondOfMinute(0);
        date = date.withMillisOfSecond(0);

        LocalDateTime endDate = new LocalDateTime(date);
        endDate = endDate.plusHours(periodLengthHour).plusMinutes(periodLengthMinute);

        ShiftTile shiftTile = new ShiftTile(
                Xray.getInstance().getTimeInvestmentControl().getShiftsInPeriod(shifts, date, endDate));
        this.getChildren().add(shiftTile);

    }// w ww .  j a v a 2  s  .  co m
}

From source file:view.schema.AssignedRoomRow.java

public AssignedRoomRow(Room room, ArrayList<TimeInvestment> shifts, LocalDateTime startTime, int startHour,
        int startMinute, int periodLengthHour, int periodLengthMinute) {
    this.startTime = startTime;
    this.room = room;
    this.shifts = shifts;

    roomLabel = new RoomTile(room.getRoomName());

    //Tilfj rumnavn til venstre.
    this.getChildren().add(roomLabel);

    //Tilfj vagter til dagene p ugen. i0 = mandag, i4 = fredag.
    for (int i = 0; i < 5; i++) {
        LocalDateTime date = startTime.plusDays(i);
        date = date.withField(DateTimeFieldType.hourOfDay(), startHour);
        date = date.withField(DateTimeFieldType.minuteOfHour(), startMinute);
        //Nulstil sekunder og millisekunder (vigtigt).
        date = date.withSecondOfMinute(0);
        date = date.withMillisOfSecond(0);

        LocalDateTime endDate = new LocalDateTime(date);
        endDate = endDate.plusHours(periodLengthHour).plusMinutes(periodLengthMinute);

        ShiftTile shiftTile = new ShiftTile(
                Xray.getInstance().getTimeInvestmentControl().getShiftsInPeriod(shifts, date, endDate));

        this.getChildren().add(shiftTile);
    }/*from   w w  w .ja  v a2s.com*/

}

From source file:view.schema.Schedule.java

public Schedule(ArrayList<TimeInvestment> timeInvestments, LocalDateTime startTime) {
    this.timeInvestments = timeInvestments;
    this.startTime = startTime;
    this.setFocusTraversable(false);

    //Tilfj headeren med ugens dage fra mandag til fredag:
    ScheduleHeader sh = new ScheduleHeader(startTime.getWeekOfWeekyear());
    scheduleListItems.add(sh);//from   w  ww .  jav a 2 s . co m
    gridLayoutlist.add(sh.getChildrenList());

    try {
        addShiftTiles();
    } catch (DatabaseException ex) {
        exceptionPopup.display(ex.getMessage());
    }

    AssignedAllRoomsRow arAfternoon = new AssignedAllRoomsRow("Eftermiddag", startTime, timeInvestments, 15, 15,
            5, 0);
    scheduleListItems.add(arAfternoon);
    gridLayoutlist.add(arAfternoon.getChildrenList());
    AssignedAllRoomsRow arNight = new AssignedAllRoomsRow("Nat", startTime, timeInvestments, 23, 15, 5, 0);
    scheduleListItems.add(arNight);
    gridLayoutlist.add(arNight.getChildrenList());

    WeekendRow wrSaturday = new WeekendRow("Lrdag", startTime.plusDays(5), timeInvestments);
    WeekendRow wrSunday = new WeekendRow("Sndag", startTime.plusDays(6), timeInvestments);
    scheduleListItems.add(wrSaturday);
    scheduleListItems.add(wrSunday);
    gridLayoutlist.add(wrSaturday.getChildrenList());
    gridLayoutlist.add(wrSunday.getChildrenList());

    this.setContent(grid);

    grid.setStyle("-fx-background-color: #FFF;");
    addGridConstraints();

    for (int i = 0; i < scheduleListItems.size(); i++) {

        if (i > (scheduleListItems.size() - 1) - 2) {
            GridPane.setColumnSpan(scheduleListItems.get(i).getChildrenList()[1], 5);
        }

        grid.addRow(i, scheduleListItems.get(i).getChildrenList());

    }

    VBox.setVgrow(this, Priority.ALWAYS);

    this.setFitToWidth(true);
}