List of usage examples for org.joda.time LocalDateTime getWeekOfWeekyear
public int getWeekOfWeekyear()
From source file:com.kccomy.orgar.util.DateFormatUtil.java
License:Apache License
public static String getFormattedDate(Date date) { LocalDateTime modified = LocalDateTime.fromDateFields(date); LocalDateTime now = LocalDateTime.now(); if (modified.getWeekOfWeekyear() == now.getWeekOfWeekyear() && modified.getYear() == now.getYear()) { if (modified.getDayOfWeek() == now.getDayOfWeek()) { return modified.toString(TIME); } else {/*from w w w . ja va 2 s . com*/ return modified.toString(WEEK); } } else { return modified.toString(DATE); } }
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 www. ja va2s. 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);// www .j av a 2s . 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);// w ww . ja v a2 s .co m 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.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);/* w w w .ja va 2 s. c o 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); }