List of usage examples for java.time YearMonth now
public static YearMonth now()
From source file:Main.java
public static void main(String[] args) { TemporalQuery<TemporalUnit> precision = TemporalQueries.precision(); System.out.println(LocalDate.now().query(precision)); // Days System.out.println(LocalTime.now().query(precision)); // Nanos System.out.println(YearMonth.now().query(precision)); // Months }
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 w ww . j a va 2 s .c om*/ 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:de.lgblaumeiser.ptm.analysis.analyzer.ProjectComputer.java
private Collection<Booking> getRelevantBookings(final Collection<String> dayOrMonthParameter) { if (dayOrMonthParameter.size() > 0) { String dayOrMonthString = Iterables.get(dayOrMonthParameter, 0); if (dayOrMonthString.length() == 10) { return getBookingsForDay(LocalDate.parse(dayOrMonthString)); }// ww w . j a v a 2 s . c o m if (dayOrMonthString.length() == 7) { return getBookingsForMonth(YearMonth.parse(dayOrMonthString)); } } return getBookingsForMonth(YearMonth.now()); }
From source file:fr.lepellerin.ecole.web.controller.cantine.DetaillerReservationRepasController.java
/** * initialise le form.// www . j a va 2 s.com * * @return <code>DetaillerReservationRepasForm</code> */ @ModelAttribute("command") public DetaillerReservationRepasForm addCommand() { final DetaillerReservationRepasForm form = new DetaillerReservationRepasForm(); final YearMonth moisActuel = YearMonth.now(); final Integer intMois = Integer .valueOf(moisActuel.format(DateTimeFormatter.ofPattern(GeDateUtils.DATE_FORMAT_YYYYMM))); form.setAnneeMois(intMois); return form; }
From source file:fr.lepellerin.ecole.service.internal.CantineServiceImpl.java
@Override @Transactional(readOnly = true)/*from www .ja v a 2s . c o m*/ 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; }