Example usage for org.joda.time LocalDateTime getDayOfWeek

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

Introduction

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

Prototype

public int getDayOfWeek() 

Source Link

Document

Get the day of week field value.

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.  ja va  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.popups.AssignRoomsPopup.java

@Override
public void display(String title) {
    cBDateTimeStart = new ComboBox();
    cBDateTimeEnd = new ComboBox();
    assignRooms = new PopupMenuButton("Tilfj inaktive rum i tidsperioden");
    localDateTimeObject = LocalDateTime.now();

    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override//from  w w  w  . j a v  a  2  s.c  o  m
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {

                        String value = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        value = value.replaceFirst(value.substring(1, value.length()),
                                value.substring(1, value.length()).toLowerCase());

                        setText("Uge " + item.getWeekOfWeekyear() + " den " + item.getDayOfMonth() + "/"
                                + item.getMonthOfYear() + " - " + value);
                    }
                }

            };
        }
    };

    cBDateTimeStart.setButtonCell(cellFactory.call(null));
    cBDateTimeStart.setCellFactory(cellFactory);

    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory2 = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String value = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        value = value.replaceFirst(value.substring(1, value.length()),
                                value.substring(1, value.length()).toLowerCase());
                        setText("Uge " + item.getWeekOfWeekyear() + " den " + item.getDayOfMonth() + "/"
                                + item.getMonthOfYear() + " - " + value);
                    }
                }

            };
        }
    };

    cBDateTimeEnd.setButtonCell(cellFactory2.call(null));
    cBDateTimeEnd.setCellFactory(cellFactory2);

    setBottomHBoxPadding(15, 15, 15, 15);
    cBContainer = new VBox(20);
    cBContainer.setAlignment(Pos.CENTER);
    cBContainer.setPadding(new Insets(15, 15, 15, 15));
    super.addToCenter(cBContainer);
    cBContainer.getChildren().addAll(cBDateTimeStart, cBDateTimeEnd);
    super.getBottomHBox().getChildren().add(0, assignRooms);

    assignRooms.setOnAction(e -> {

    });
}

From source file:view.popups.shift.ShiftManualPopup.java

private void initComboboxes() {
    cWeek = new ComboBox();
    cWeek.setPrefWidth(170);/*from w  w w.  j a v  a  2  s .com*/

    ArrayList<LocalDateTime> mondays = getTwelveMondays();
    for (int i = 0; i < mondays.size(); i++) {
        cWeek.getItems().add(mondays.get(i));
    }

    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String value = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        value = value.replaceFirst(value.substring(1, value.length()),
                                value.substring(1, value.length()).toLowerCase());
                        setText("Uge " + item.getWeekOfWeekyear() + " den " + item.getDayOfMonth() + "/"
                                + item.getMonthOfYear() + " - " + value);
                    }
                }

            };
        }
    };

    cWeek.setButtonCell(cellFactory.call(null));
    cWeek.setCellFactory(cellFactory);

    cEmployee = new ComboBox();
    cEmployee.setPrefWidth(170);
    cEmployee.setDisable(true);

    cRoom = new ComboBox();
    cRoom.setPrefWidth(170);
    cRoom.setDisable(true);

}

From source file:view.popups.shift.ShiftPopup.java

private void initComboboxes() {

    cDate = new ComboBox();
    cDate.setPrefWidth(170);/*from w ww.j  a v  a 2s .com*/

    LocalDateTime now = new LocalDateTime();
    now = now.withHourOfDay(0);
    now = now.withMinuteOfHour(0);
    LocalDateTime currentWeek = now;

    LocalDateTime threeMonthsForward = now.plusMonths(3);
    ArrayList<LocalDateTime> startDates = Xray.getInstance().getDatesInPeriod(currentWeek, threeMonthsForward);
    for (int i = 0; i < startDates.size(); i++) {
        if (startDates.get(i).getDayOfWeek() == 1) {
            cDate.getItems().add(startDates.get(i));
        }
    }

    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String value = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        value = value.replaceFirst(value.substring(1, value.length()),
                                value.substring(1, value.length()).toLowerCase());
                        setText("Uge " + item.getWeekOfWeekyear() + " den " + item.getDayOfMonth() + "/"
                                + item.getMonthOfYear() + " - " + value);
                    }
                }

            };
        }
    };

    cDate.setButtonCell(cellFactory.call(null));
    cDate.setCellFactory(cellFactory);

    cEmployee = new ComboBox();
    cEmployee.setPrefWidth(170);
    cEmployee.setDisable(true);

}

From source file:view.popups.TimeInvestmentPopup.java

private void fillContent() {
    //Fyld datoer ind i comboboks til start og slutdato:
    LocalDateTime now = new LocalDateTime();
    LocalDateTime oneWeekBack = now.minusMonths(12);
    LocalDateTime oneMonthForward = now.plusMonths(12);
    ArrayList<LocalDateTime> startDates = Xray.getInstance().getDatesInPeriod(oneWeekBack, oneMonthForward);
    for (int i = 0; i < startDates.size(); i++) {
        cStart.getItems().add(startDates.get(i));
    }/* w ww  . j a v a 2  s .c  o m*/
    cStart.getSelectionModel().selectFirst();

    //Lav et cellfactory p comboboksen s datoerne vises overskueligt.
    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String dayName = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        setText(item.toString("dd/MM/yy") + " " + dayName.substring(0, 1)
                                + dayName.substring(1).toLowerCase());
                    }
                }

            };
        }
    };

    Xray.getInstance().fillDatesInEndDate(cEnd, cStart, 12);

    cStart.setButtonCell(cellFactory.call(null));
    cStart.setCellFactory(cellFactory);
    cEnd.setButtonCell(cellFactory.call(null));
    cEnd.setCellFactory(cellFactory);

}

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

private void fillContent() {
    try {/*  w w w. j  a  va  2 s .c o  m*/
        ArrayList<Employee> employees = Xray.getInstance().getPersonControl().getEmployees();

        for (int i = 0; i < employees.size(); i++) {
            cEmp.getItems().add(employees.get(i));
        }
        cEmp.getSelectionModel().selectFirst();
    } catch (DatabaseException ex) {
        new ExceptionPopup().display(ex.getMessage());
    }

    try {
        ArrayList<Room> rooms = Xray.getInstance().getRoomControl().getRooms();

        for (int i = 0; i < rooms.size(); i++) {
            cRoom.getItems().add(rooms.get(i));
        }
        cRoom.getSelectionModel().selectFirst();
    } catch (DatabaseException ex) {
        new ExceptionPopup().display(ex.getMessage());
    }

    //Fyld datoer ind i comboboks til start og slutdato:
    LocalDateTime now = new LocalDateTime();
    LocalDateTime oneWeekBack = now.minusDays(7);
    LocalDateTime oneMonthForward = now.plusMonths(1);
    ArrayList<LocalDateTime> startDates = Xray.getInstance().getDatesInPeriod(oneWeekBack, oneMonthForward);
    for (int i = 0; i < startDates.size(); i++) {
        cStart.getItems().add(startDates.get(i));
    }
    cStart.getSelectionModel().selectFirst();

    //Lav et cellfactory p comboboksen s datoerne vises overskueligt.
    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String dayName = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        setText(item.toString("dd/MM") + " " + dayName.substring(0, 1)
                                + dayName.substring(1).toLowerCase());
                    }
                }

            };
        }
    };

    Xray.getInstance().fillDatesInEndDate(cEnd, cStart, 1);

    cStart.setButtonCell(cellFactory.call(null));
    cStart.setCellFactory(cellFactory);
    cEnd.setButtonCell(cellFactory.call(null));
    cEnd.setCellFactory(cellFactory);

}