List of usage examples for java.time YearMonth from
public static YearMonth from(TemporalAccessor temporal)
From source file:Main.java
public static void main(String[] args) { YearMonth y = YearMonth.from(LocalDate.now()); System.out.println(y); }
From source file:de.lgblaumeiser.ptm.analysis.analyzer.ProjectComputer.java
private Collection<Booking> getBookingsForMonth(final YearMonth month) { return store.retrieveAll().stream().filter(b -> month.equals(YearMonth.from(b.getBookingday()))) .collect(Collectors.toList()); }
From source file:com.github.drbookings.LocalDates.java
public static boolean isNextMonth(YearMonth selectedMonth, LocalDate date) { return YearMonth.from(date).equals(selectedMonth.plusMonths(1)); }
From source file:com.github.drbookings.LocalDates.java
public static boolean isPrevMonth(YearMonth selectedMonth, LocalDate date) { return YearMonth.from(date).equals(selectedMonth.minusMonths(1)); }
From source file:fr.lepellerin.ecole.service.internal.CantineServiceImpl.java
@Override @Transactional(readOnly = true)/*from w ww. j a v a 2s .c om*/ public List<ComboItemDto> getMoisOuvertCantine() throws TechnicalException { final Activite activite = this.getCantineActivite(); final List<Ouverture> ouvertures = this.ouvertureRepository.findByActivite(activite); final Set<YearMonth> moisActs = new HashSet<>(); moisActs.add(YearMonth.now()); ouvertures.sort((o1, o2) -> o1.getDate().compareTo(o2.getDate())); ouvertures.forEach(o -> { moisActs.add(YearMonth.from(((java.sql.Date) o.getDate()).toLocalDate())); }); final List<ComboItemDto> comboMois = new ArrayList<>(); moisActs.forEach(ma -> { final Integer id = Integer .valueOf(ma.format(DateTimeFormatter.ofPattern(GeDateUtils.DATE_FORMAT_YYYYMM))); final String libelle = ma.format(DateTimeFormatter.ofPattern(GeDateUtils.DATE_FORMAT_ANNEE_MOIS_FULL)); comboMois.add(new ComboItemDto(id, libelle)); }); comboMois.sort((c1, c2) -> c1.getId().compareTo(c2.getId())); return comboMois; }
From source file:com.github.drbookings.ui.controller.MainController.java
private void selectPrevMonthFX() { setWorking(true);/*w w w . j a va 2 s . c om*/ final int[] monthIndices = getPrevMonthIndicies(YearMonth.from(getSelectedDate())); tableView.sort(); tableView.getSelectionModel().selectIndices(monthIndices[0], monthIndices); setWorking(false); }
From source file:com.github.drbookings.ui.controller.MainController.java
private void selectNextMonthFX() { setWorking(true);/*from w w w. j ava 2 s .com*/ final int[] monthIndices = getNextMonthIndicies(YearMonth.from(getSelectedDate())); tableView.sort(); tableView.getSelectionModel().selectIndices(monthIndices[0], monthIndices); setWorking(false); }
From source file:sg.ncl.MainController.java
private void differentiateProjects(List<ProjectDetails> newProjects, List<ProjectDetails> activeProjects, List<ProjectDetails> inactiveProjects, List<ProjectDetails> stoppedProjects, YearMonth m_s, YearMonth m_e, ProjectDetails project) { YearMonth created = YearMonth.from(project.getZonedDateCreated()); YearMonth m_e_m1 = m_e.minusMonths(1); YearMonth m_e_m2 = m_e.minusMonths(2); YearMonth m_active = m_e_m2.isBefore(m_s) ? m_e_m2 : m_s; // projects created within the period if (!(created.isBefore(m_s) || created.isAfter(m_e))) { newProjects.add(project);//from w ww. j a va2 s . c o m } // active projects = projects with resources within the period + projects created boolean hasUsage = project.getProjectUsages().stream().anyMatch(p -> p.hasUsageWithinPeriod(m_active, m_e)); if (hasUsage || !(created.isBefore(m_e_m2) || created.isAfter(m_e))) { activeProjects.add(project); } // inactive projects if (!hasUsage && created.isBefore(m_e_m2)) { inactiveProjects.add(project); } // stopped projects boolean hasUsagePreviousMonth = project.getProjectUsages().stream() .anyMatch(p -> p.hasUsageWithinPeriod(m_e_m1, m_e_m1)); boolean hasUsageCurrentMonth = project.getProjectUsages().stream() .anyMatch(p -> p.hasUsageWithinPeriod(m_e, m_e)); if (hasUsagePreviousMonth && !hasUsageCurrentMonth) { stoppedProjects.add(project); } }