List of usage examples for java.time YearMonth isBefore
public boolean isBefore(YearMonth other)
From source file:Main.java
public static void main(String[] args) { YearMonth y = YearMonth.now(); System.out.println(y.isBefore(YearMonth.now())); }
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 w w. ja v a2 s .c om } // 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); } }