List of usage examples for java.time YearMonth atEndOfMonth
public LocalDate atEndOfMonth()
From source file:Main.java
public static void main(String[] args) { YearMonth y = YearMonth.now(); LocalDate l = y.atEndOfMonth(); System.out.println(l);/*from w w w . j a v a 2s.c o m*/ }
From source file:Main.java
private static boolean stillInCalendar(YearMonth yearMonth, LocalDate day) { return !day.isAfter(yearMonth.atEndOfMonth()); }
From source file:fr.lepellerin.ecole.service.internal.CantineServiceImpl.java
@Override @Transactional(readOnly = true)/*from www.j a v a2 s.c o m*/ public PlanningDto getDateOuvert(final YearMonth anneeMois, final Famille famille) throws TechnicalException { final Date startDate = Date.from(Instant.from(anneeMois.atDay(1).atStartOfDay(ZoneId.systemDefault()))); final Date endDate = Date.from(Instant.from(anneeMois.atEndOfMonth().atStartOfDay(ZoneId.systemDefault()))); final Activite activite = getCantineActivite(); final LocalDateTime heureH = LocalDateTime.now(); final List<Inscription> icts = this.ictRepository.findByActiviteAndFamille(activite, famille); final PlanningDto planning = new PlanningDto(); icts.forEach(ict -> { planning.getHeaders().add(ict.getIndividu().getPrenom()); final List<Consommation> consos = this.consommationRepository .findByFamilleInscriptionActiviteUniteEtatsPeriode(famille, activite, ict.getGroupe(), Arrays.asList("reservation"), startDate, endDate); final List<Ouverture> ouvertures = this.ouvertureRepository.findByActiviteAndGroupeAndPeriode(activite, ict.getGroupe(), startDate, endDate); ouvertures.forEach(o -> { final LocalDate date = LocalDate.from(((java.sql.Date) o.getDate()).toLocalDate()); final LocalDateTime heureResa = this.getLimiteResaCantine(date); final LigneDto ligne = planning.getOrCreateLigne(date); final CaseDto c = new CaseDto(); c.setDate(date); c.setIndividu(ict.getIndividu()); c.setActivite(o.getActivite()); c.setUnite(o.getUnite()); c.setReservable(heureResa.isAfter(heureH)); final Optional<Consommation> cOpt = consos.stream().filter(conso -> { final LocalDate dateConso = LocalDate.from(((java.sql.Date) conso.getDate()).toLocalDate()); return dateConso.equals(date); }).findAny(); c.setReserve(cOpt.isPresent()); ligne.getCases().add(c); }); }); return planning; }
From source file:de.lgblaumeiser.ptm.analysis.analyzer.HourComputer.java
@Override public Collection<Collection<Object>> analyze(final Collection<String> parameter) { YearMonth requestedMonth = YearMonth.now(); if (parameter.size() > 0) { requestedMonth = YearMonth.parse(Iterables.get(parameter, 0)); }/*from ww w. j a v a2 s. c o m*/ Collection<Collection<Object>> result = Lists.newArrayList(); result.add(Arrays.asList("Work Day", "Starttime", "Endtime", "Presence", "Worktime", "Breaktime", "Overtime", "Comment")); Duration overtime = Duration.ZERO; LocalDate currentday = requestedMonth.atDay(1); while (!currentday.isAfter(requestedMonth.atEndOfMonth())) { Collection<Booking> currentBookings = getBookingsForDay(currentday); if (hasCompleteBookings(currentBookings)) { String day = currentday.format(DateTimeFormatter.ISO_LOCAL_DATE); LocalTime starttime = Iterables.getFirst(currentBookings, null).getStarttime(); LocalTime endtime = Iterables.getLast(currentBookings).getEndtime(); Duration presence = calculatePresence(starttime, endtime); Duration worktime = calculateWorktime(currentBookings); Duration breaktime = calculateBreaktime(presence, worktime); Duration currentOvertime = calculateOvertime(worktime, currentday); overtime = overtime.plus(currentOvertime); result.add(Arrays.asList(day, starttime.format(DateTimeFormatter.ofPattern("HH:mm")), endtime.format(DateTimeFormatter.ofPattern("HH:mm")), formatDuration(presence), formatDuration(worktime), formatDuration(breaktime), formatDuration(overtime), validate(worktime, breaktime))); } currentday = currentday.plusDays(1); } return result; }
From source file:org.silverpeas.core.calendar.CalendarEventOccurrenceGenerationTest.java
private Period in(YearMonth yearMonth) { return Period.between(yearMonth.atDay(1).atStartOfDay().atOffset(ZoneOffset.UTC), yearMonth.atEndOfMonth().plusDays(1).atStartOfDay().minusMinutes(1).atOffset(ZoneOffset.UTC)); }