List of usage examples for org.joda.time LocalDateTime minusMonths
public LocalDateTime minusMonths(int months)
From source file:com.axelor.csv.script.ImportDateTime.java
License:Open Source License
public LocalDateTime updateMonth(LocalDateTime dateTime, String month) { if (!Strings.isNullOrEmpty(month)) { Matcher matcher = patternMonth.matcher(month); if (matcher.find()) { Integer months = Integer.parseInt(matcher.group()); if (month.startsWith("+")) dateTime = dateTime.plusMonths(months); else if (month.startsWith("-")) dateTime = dateTime.minusMonths(months); else/*from w w w . ja v a 2s . c o m*/ dateTime = dateTime.withMonthOfYear(months); } } return dateTime; }
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 av a 2 s . co 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); }