List of usage examples for java.time.temporal ChronoUnit WEEKS
ChronoUnit WEEKS
To view the source code for java.time.temporal ChronoUnit WEEKS.
Click Source Link
From source file:nu.yona.server.analysis.service.ActivityService.java
private List<WeekActivityOverviewDto> getWeekActivityOverviews(UUID userAnonymizedId, Set<IntervalInactivityDto> missingInactivities, UserAnonymizedDto userAnonymized, Interval interval) { Map<LocalDate, Set<WeekActivity>> weekActivityEntitiesByLocalDate = getWeekActivitiesGroupedByDate( userAnonymizedId, interval); Map<ZonedDateTime, Set<WeekActivity>> weekActivityEntitiesByZonedDate = mapToZonedDateTime( weekActivityEntitiesByLocalDate); Map<ZonedDateTime, Set<WeekActivityDto>> weekActivityDtosByZonedDate = mapWeekActivitiesToDtos( weekActivityEntitiesByZonedDate); addMissingInactivity(userAnonymized.getGoals(), weekActivityDtosByZonedDate, interval, ChronoUnit.WEEKS, userAnonymized,//from ww w . j ava 2 s .c o m (goal, startOfWeek) -> createAndSaveWeekInactivity(userAnonymized, goal, startOfWeek, LevelOfDetail.WEEK_OVERVIEW, missingInactivities), (g, wa) -> createAndSaveInactivityDays(userAnonymized, userAnonymized.getGoalsForActivityCategory(g.getActivityCategory()), wa, missingInactivities)); return weekActivityDtosByZonedDate.entrySet().stream() .sorted((e1, e2) -> e2.getKey().compareTo(e1.getKey())) .map(e -> WeekActivityOverviewDto.createInstance(e.getKey(), e.getValue())) .collect(Collectors.toList()); }
From source file:nu.yona.server.analysis.service.ActivityService.java
private WeekActivityDto getWeekActivityDetail(UUID userId, UUID userAnonymizedId, LocalDate date, UUID goalId, Set<IntervalInactivityDto> missingInactivities) { UserAnonymizedDto userAnonymized = userAnonymizedService.getUserAnonymized(userAnonymizedId); WeekActivity weekActivityEntity = weekActivityRepository.findOne(userAnonymizedId, date, goalId); if (weekActivityEntity == null) { return getMissingInactivity(userId, date, goalId, userAnonymized, ChronoUnit.WEEKS, (goal, startOfWeek) -> createAndSaveWeekInactivity(userAnonymized, goal, startOfWeek, LevelOfDetail.WEEK_DETAIL, missingInactivities)); }/* w w w . j a va 2 s .c o m*/ WeekActivityDto weekActivityDto = WeekActivityDto.createInstance(weekActivityEntity, LevelOfDetail.WEEK_DETAIL); weekActivityDto.createRequiredInactivityDays(userAnonymized, userAnonymized.getGoalsForActivityCategory(weekActivityEntity.getGoal().getActivityCategory()), LevelOfDetail.WEEK_DETAIL, missingInactivities); return weekActivityDto; }
From source file:org.silverpeas.core.calendar.Recurrence.java
private Temporal computeDateForMonthlyFrequencyFrom(final Temporal source, DayOfWeekOccurrence dayOfWeek) { Temporal current = source;/*ww w . j av a 2 s . c o m*/ if (dayOfWeek.nth() > 1) { current = current.with(ChronoField.ALIGNED_WEEK_OF_MONTH, dayOfWeek.nth()); } else if (dayOfWeek.nth() < 0) { current = current.with(ChronoField.DAY_OF_MONTH, 1).plus(1, ChronoUnit.MONTHS).minus(1, ChronoUnit.DAYS) .plus(dayOfWeek.nth(), ChronoUnit.WEEKS).with(dayOfWeek.dayOfWeek()); } return current; }
From source file:org.silverpeas.core.calendar.Recurrence.java
private Temporal computeDateForYearlyFrequencyFrom(final Temporal source, DayOfWeekOccurrence dayOfWeek) { final int lastDayOfYear = 31; Temporal current = source;//w w w .j a v a 2 s . c o m if (dayOfWeek.nth() > 1) { current = current.with(ChronoField.ALIGNED_WEEK_OF_YEAR, dayOfWeek.nth()); } else if (dayOfWeek.nth() < 0) { current = current.with(MonthDay.of(Month.DECEMBER, lastDayOfYear)) .plus(dayOfWeek.nth(), ChronoUnit.WEEKS).with(dayOfWeek.dayOfWeek()); } return current; }