List of usage examples for java.time.temporal ChronoUnit DAYS
ChronoUnit DAYS
To view the source code for java.time.temporal ChronoUnit DAYS.
Click Source Link
From source file:nu.yona.server.analysis.service.ActivityService.java
private Page<DayActivityOverviewDto<DayActivityDto>> getDayActivityOverviews(UUID userAnonymizedId, Pageable pageable, Set<IntervalInactivityDto> missingInactivities) { UserAnonymizedDto userAnonymized = userAnonymizedService.getUserAnonymized(userAnonymizedId); Interval interval = getInterval(getCurrentDayDate(userAnonymized), pageable, ChronoUnit.DAYS); List<DayActivityOverviewDto<DayActivityDto>> dayActivityOverviews = getDayActivityOverviews( missingInactivities, userAnonymized, interval); return new PageImpl<>(dayActivityOverviews, pageable, getTotalPageableItems(userAnonymized, ChronoUnit.DAYS)); }
From source file:com.orange.cepheus.broker.controller.NgsiControllerTest.java
@Test public void postUpdateContextWithoutProvidingApplicationAndWithoutRemoteBrokerButWithNotify() throws Exception { when(configuration.getRemoteUrl()).thenReturn(null); //localRegistrations mock return always without providingApplication when(providingApplication.hasNext()).thenReturn(false); when(localRegistrations.findProvidingApplication(any(), any())).thenReturn(providingApplication); //subscriptions mock return always with matched subscriptions when(matchedSubscriptions.hasNext()).thenReturn(true, false); SubscribeContext subscribeContext = createSubscribeContextTemperature(); Subscription subscription = new Subscription("999999", Instant.now().plus(1, ChronoUnit.DAYS), subscribeContext);// w w w .ja v a2 s. c o m when(matchedSubscriptions.next()).thenReturn(subscription); when(subscriptions.findSubscriptions(any(), any())).thenReturn(matchedSubscriptions); //ngsiclient mock return always createUpdateContextREsponseTemperature when call updateContext when(ngsiClient.updateContext(any(), any(), any())).thenReturn(updateContextResponseListenableFuture); //ngsiClient mock return always CODE_200 when(ngsiClient.notifyContext(any(), any(), any())).thenReturn(notifyContextResponseListenableFuture); mockMvc.perform(post("/v1/updateContext").content(json(mapper, createUpdateContextTempSensorAndPressure())) .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$.errorCode").doesNotExist()) .andExpect(MockMvcResultMatchers.jsonPath("$.contextElementResponses[0].contextElement.id") .value("S1")) .andExpect(MockMvcResultMatchers.jsonPath("$.contextElementResponses[0].contextElement.type") .value("TempSensor")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[0].name").value("temp")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[0].type").value("float")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[0].value").value("15.5")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[1].name") .value("pressure")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[1].type").value("int")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[1].value").value("1015")) .andExpect(MockMvcResultMatchers.jsonPath("$.contextElementResponses[0].statusCode.code") .value("200")); //Capture attributes (Set<String> searchAttributes) when findProvidingApplication is called on localRegistrations Set<String> searchAttributes verify(localRegistrations).findProvidingApplication(entityIdArgumentCaptor.capture(), attributeArgumentCaptor.capture()); //check entityId assertEquals("S1", entityIdArgumentCaptor.getValue().getId()); assertEquals("TempSensor", entityIdArgumentCaptor.getValue().getType()); assertFalse(entityIdArgumentCaptor.getValue().getIsPattern()); //check attributes assertEquals(2, attributeArgumentCaptor.getValue().size()); assertTrue(attributeArgumentCaptor.getValue().contains("temp")); assertTrue(attributeArgumentCaptor.getValue().contains("pressure")); //check ListenableFuture is called never and with addCallback method verify(updateContextResponseListenableFuture, never()).addCallback(any(), any()); //verify ngsiClient.updateContext is never called verify(ngsiClient, never()).updateContext(any(), any(), any()); //check ngsiClient.notify is called at least once // Capture notifyContext when postNotifyContextRequest is called on updateContextRequest, ArgumentCaptor<NotifyContext> notifyContextArg = ArgumentCaptor.forClass(NotifyContext.class); verify(notifyContextResponseListenableFuture, atLeastOnce()).addCallback(any(), any()); String urlReference = subscribeContext.getReference().toString(); verify(ngsiClient, atLeastOnce()).notifyContext(eq(urlReference), any(), notifyContextArg.capture()); // Check id and status correspond to the required assertEquals(1, notifyContextArg.getValue().getContextElementResponseList().size()); ContextElementResponse contextElementResponse = notifyContextArg.getValue().getContextElementResponseList() .get(0); assertEquals("S1", contextElementResponse.getContextElement().getEntityId().getId()); assertEquals("200", contextElementResponse.getStatusCode().getCode()); }
From source file:com.example.app.profile.ui.user.ProfileMembershipManagement.java
@Override public void init() { super.init(); setValidator(CompositeValidator.of((component, notifiable) -> validateSupporters(notifiable), (component, notifiable) -> { if (_requiredMembershipTypes.isEmpty()) return true; final HashSet<MembershipType> toCheck = new HashSet<>(_requiredMembershipTypes); getProfile().getMembershipSet() .forEach(membership -> toCheck.remove(membership.getMembershipType())); toCheck.forEach(mt -> { NotificationImpl notification = new NotificationImpl(NotificationType.ERROR, createText(CommonValidationText.ARG0_IS_REQUIRED, mt.getName())); notification.setSource(this); notifiable.sendNotification(notification); });/*from w w w.j a v a 2 s . c o m*/ return toCheck.isEmpty(); })); User currentUser = _userDAO.getAssertedCurrentUser(); Hibernate.initialize(currentUser); Hibernate.initialize(currentUser.getPrincipal()); Hibernate.initialize(currentUser.getPrincipal().getContact()); final Profile adminProfile = getProfile(); final TimeZone timeZone = getSession().getTimeZone(); boolean isAdminish = _profileDAO.canOperate(currentUser, adminProfile, timeZone, _mop.modifyCompany()); if (!_profileDAO.canOperate(currentUser, adminProfile, timeZone, _mop.modifyUserRoles())) { Label label = new Label(INSUFFICIENT_PERMISSIONS(MEMBERSHIP())).withHTMLElement(HTMLElement.h3); setDefaultComponent(label); return; } final SimpleDateFormat dateFormat = getDateFormat(getLocaleContext().getLocale()); dateFormat.setTimeZone(getSession().getTimeZone()); final DateFormatLabel dateRenderer = new DateFormatLabel(dateFormat) { @Override public Component getTableCellRendererComponent(Table table, Object cellValue, boolean isSelected, boolean hasFocus, int row, int column) { Date value = (Date) cellValue; value = toDate(convertFromPersisted(value, getSession().getTimeZone())); return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }; final NamedObjectComparator nocComparator = new NamedObjectComparator(getLocaleContext()); FixedValueColumn actionColumn = new FixedValueColumn(); actionColumn.setColumnName(CommonColumnText.ACTIONS); PropertyColumn userColumn = new PropertyColumn(Membership.class, Membership.USER_PROP); userColumn.setColumnName(CommonColumnText.USER); userColumn.setComparator(nocComparator); PropertyColumn membershipTypeColumn = new PropertyColumn(Membership.class, Membership.MEMBERSHIP_TYPE_PROP); membershipTypeColumn.setColumnName(MEMBERSHIP_TYPE()); membershipTypeColumn.setComparator(nocComparator); PropertyColumn membershipDStartColumn = new PropertyColumn(Membership.class, Membership.START_DATE_PROP); membershipDStartColumn.setColumnName(START_DATE()); membershipDStartColumn.setComparator(ComparableComparator.getInstance()); PropertyColumn membershipDEndColumn = new PropertyColumn(Membership.class, Membership.END_DATE_PROP); membershipDEndColumn.setComparator(ComparableComparator.getInstance()); membershipDEndColumn.setColumnName(END_DATE()); _membershipTable = isAllowEditActive() ? new DataColumnTable<>(actionColumn, userColumn, membershipTypeColumn, membershipDStartColumn, membershipDEndColumn) : new DataColumnTable<>(actionColumn, userColumn, membershipTypeColumn); _membershipTable.setTableCellRenderer(dateRenderer, Date.class); _membershipTable.getDefaultModel().setAutoReattachEntities(false); _membershipTable.setRowModel(new RowModelImpl() { @Override public Row getRow(Table table, int row) { final Row r = super.getRow(table, row); final Membership membership = _membershipTable.getDefaultModel().getRow(row); if (membership.isActive()) { r.removeClassName("member-inactive"); r.addClassName("member-active"); } else { r.addClassName("member-inactive"); r.removeClassName("member-active"); } return r; } }); QLResolverOptions resolverOptions = new QLResolverOptions(); resolverOptions.setFetchSize(1); resolverOptions.setCacheRegion(ProjectCacheRegions.MEMBER_QUERY); PushButton editOperationsBtn = new PushButton(BUTTON_TEXT_MODIFY()) { @Override public Component getTableCellRendererComponent(Table table, @Nullable Object value, boolean isSelected, boolean hasFocus, int row, int column) { Membership mem = (Membership) value; boolean hasOperations = false; if (mem != null) { final QLBuilderImpl qb = new QLBuilderImpl(ProfileType.class, "ptAlias"); qb.setQLResolverOptions(resolverOptions); qb.appendCriteria("id", PropertyConstraint.Operator.eq, mem.getProfile().getProfileType().getId()); final JoinedQLBuilder mtQB = qb.createInnerJoin(ProfileType.MEMBERSHIP_TYPES_PROP); final JoinedQLBuilder opQB = mtQB.createInnerJoin(MembershipType.DEFAULT_OPERATIONS_PROP); qb.setProjection("COUNT(DISTINCT %s)", opQB.getAlias()); try (CloseableIterator<?> it = qb.getQueryResolver().iterate()) { if (it.hasNext()) { final Number next = (Number) it.next(); hasOperations = next.intValue() > 0; } } } setVisible(hasOperations && isAdminish); return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }; editOperationsBtn.addActionListener(eev -> doOperationEdit(_membershipTable.getLeadSelection())); PushButton editActivationDatesBtn = new PushButton(ACTION_EDIT_DATES()); editActivationDatesBtn.setTooltip(TOOLTIP_EDIT_DATES(MEMBERSHIP())); editActivationDatesBtn.addActionListener(eev -> doDatesEdit(_membershipTable.getLeadSelection())); PushButton deactivateBtn = new PushButton(ACTION_DEACTIVATE()) { @Override public Component getTableCellRendererComponent(Table table, @Nullable Object value, boolean isSelected, boolean hasFocus, int row, int column) { Membership m = (Membership) value; assert m != null; setVisible(m.getEndDate() == null); return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }; deactivateBtn.setTooltip(TOOLTIP_DEACTIVATE()); deactivateBtn.addActionListener(ev -> { final Membership membership = _membershipTable.getLeadSelection(); assert membership != null; final Date now = convertForPersistence( getZonedDateTimeForComparison(timeZone).minus(1, ChronoUnit.DAYS)); membership.setEndDate(now); showHideConstraints(); }); PushButton deleteBtn = CommonActions.DELETE.push(); deleteBtn.getButtonDisplay().setConfirmText(DELETE_CONFIRM_TEXT_FMT(MEMBERSHIP())); deleteBtn.addActionListener(dev -> { final Membership membership = _membershipTable.getLeadSelection(); assert membership != null; membership.getProfile().getMembershipSet().remove(membership); reloadTableData(); }); Container actions = of("actions", editOperationsBtn); if (isAllowEditActive()) { actions.add(editActivationDatesBtn); actions.add(deactivateBtn); } if (isAdminish) actions.add(deleteBtn); final Column uiColumn = _membershipTable.getUIColumn(actionColumn); assert uiColumn != null; uiColumn.setDisplayClass("action-column"); _membershipTable.setUICellRenderer(actionColumn, actions); Menu menu = new Menu(CommonButtonText.ADD); menu.setTooltip(ConcatTextSource.create(CommonButtonText.ADD, MEMBERSHIP_TYPE()).withSpaceSeparator()); enableTooltip(menu); menu.addClassName("entity-action"); LocaleContext lc = getLocaleContext(); getProfile().getProfileType().getMembershipTypeSet().stream() .filter(membershipType -> !_excludedMembershipTypes.contains(membershipType)) .sorted(new NamedObjectComparator(lc)).forEach(mt -> { TextSource menuItemText = mt.getName(); MenuItem mi = new MenuItem(menuItemText); mi.addActionListener(ev -> doSelectUserAndCreateMembership(mt)); menu.add(mi); }); _activeConstraint.setSelectedObject(ACTIVE()); _activeConstraint.addActionListener(this::reloadTableData); setDefaultComponent(of("search-wrapper profile-role-search", of("entity-actions actions", menu), of("search-bar", _activeConstraint), new Pager(_membershipTable.addClassName("search-results")))); reloadTableData(); }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_appActivityOnNewDay_addActivity() { JUnitUtil.skipBefore("Skip shortly after midnight", now(), 0, 15); ZonedDateTime today = now().truncatedTo(ChronoUnit.DAYS); // mock earlier activity at yesterday 23:59:58, // add new activity at today 00:00:01 ZonedDateTime existingActivityTime = today.minusDays(1).withHour(23).withMinute(59).withSecond(58); mockExistingActivity(gamblingGoal, existingActivityTime); ZonedDateTime startTime = today.withHour(0).withMinute(0).withSecond(1); ZonedDateTime endTime = today.withHour(0).withMinute(10); service.analyze(userAnonId, deviceAnonId, createSingleAppActivity("Poker App", startTime, endTime)); verify(mockActivityUpdater).addActivity(any(), any(), eq(GoalDto.createInstance(gamblingGoal)), any()); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).updateTimeLastActivity(any(), any(), any()); }
From source file:nu.yona.server.analysis.service.ActivityService.java
private Map<ZonedDateTime, Set<DayActivityDto>> getDayActivities(UserAnonymizedDto userAnonymized, Set<GoalDto> relevantGoals, Interval interval, Set<IntervalInactivityDto> missingInactivities) { Map<LocalDate, Set<DayActivity>> dayActivityEntitiesByLocalDate = getDayActivitiesGroupedByDate( userAnonymized.getId(), relevantGoals, interval); Map<ZonedDateTime, Set<DayActivity>> dayActivityEntitiesByZonedDate = mapToZonedDateTime( dayActivityEntitiesByLocalDate); Map<ZonedDateTime, Set<DayActivityDto>> dayActivityDtosByZonedDate = mapDayActivitiesToDtos( dayActivityEntitiesByZonedDate); addMissingInactivity(relevantGoals, dayActivityDtosByZonedDate, interval, ChronoUnit.DAYS, userAnonymized, (goal, startOfDay) -> createDayInactivity(userAnonymized, goal, startOfDay, LevelOfDetail.DAY_OVERVIEW, missingInactivities), (g, a) -> { // Nothing needed here });//from w ww . j a v a 2s. co m return dayActivityDtosByZonedDate; }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_unorderedAppActivity_addedOrdered() { JUnitUtil.skipBefore("Skip shortly after midnignt", now(), 0, 10); String app = "Poker App"; ZonedDateTime today = now().truncatedTo(ChronoUnit.DAYS); ZonedDateTime t1 = today.withHour(0).withMinute(0).withSecond(1); ZonedDateTime t2 = t1.plusSeconds(15); ZonedDateTime t3 = t2.plusSeconds(1); ZonedDateTime t4 = t3.plusMinutes(5); service.analyze(userAnonId, deviceAnonId, new AppActivitiesDto(now(), new AppActivitiesDto.Activity[] { new AppActivitiesDto.Activity(app, t3, t4), new AppActivitiesDto.Activity(app, t1, t2) })); ArgumentCaptor<ActivityPayload> activityPayloadCaptor = ArgumentCaptor.forClass(ActivityPayload.class); verify(mockActivityUpdater, times(2)).addActivity(any(), activityPayloadCaptor.capture(), eq(GoalDto.createInstance(gamblingGoal)), any()); List<ActivityPayload> payloads = activityPayloadCaptor.getAllValues(); assertThat(payloads.size(), equalTo(2)); assertThat(payloads.get(0).startTime, equalTo(t1)); assertThat(payloads.get(0).endTime, equalTo(t2)); assertThat(payloads.get(1).startTime, equalTo(t3)); assertThat(payloads.get(1).endTime, equalTo(t4)); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).updateTimeLastActivity(any(), any(), any()); }
From source file:com.orange.cepheus.broker.controller.NgsiControllerTest.java
@Test public void postUpdateContextWithoutProvidingApplicationAndWithoutRemoteBrokerUrlButWithNotify() throws Exception { when(configuration.getRemoteUrl()).thenReturn(null); //localRegistrations mock return always without providingApplication when(providingApplication.hasNext()).thenReturn(false); when(localRegistrations.findProvidingApplication(any(), any())).thenReturn(providingApplication); //subscriptions mock return always with matched subscriptions when(matchedSubscriptions.hasNext()).thenReturn(true, false); SubscribeContext subscribeContext = createSubscribeContextTemperature(); Subscription subscription = new Subscription("999999", Instant.now().plus(1, ChronoUnit.DAYS), subscribeContext);/* w ww. j a v a 2 s .c o m*/ when(matchedSubscriptions.next()).thenReturn(subscription); when(subscriptions.findSubscriptions(any(), any())).thenReturn(matchedSubscriptions); //ngsiclient mock return always createUpdateContextREsponseTemperature when call updateContext when(ngsiClient.updateContext(any(), any(), any())).thenReturn(updateContextResponseListenableFuture); //ngsiClient mock return always CODE_200 when(ngsiClient.notifyContext(any(), any(), any())).thenReturn(notifyContextResponseListenableFuture); mockMvc.perform(post("/v1/updateContext").content(json(mapper, createUpdateContextTempSensorAndPressure())) .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$.errorCode").doesNotExist()) .andExpect(MockMvcResultMatchers.jsonPath("$.contextElementResponses[0].contextElement.id") .value("S1")) .andExpect(MockMvcResultMatchers.jsonPath("$.contextElementResponses[0].contextElement.type") .value("TempSensor")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[0].name").value("temp")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[0].type").value("float")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[0].value").value("15.5")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[1].name") .value("pressure")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[1].type").value("int")) .andExpect(MockMvcResultMatchers .jsonPath("$.contextElementResponses[0].contextElement.attributes[1].value").value("1015")) .andExpect(MockMvcResultMatchers.jsonPath("$.contextElementResponses[0].statusCode.code") .value("200")); //Capture attributes (Set<String> searchAttributes) when findProvidingApplication is called on localRegistrations Set<String> searchAttributes verify(localRegistrations).findProvidingApplication(entityIdArgumentCaptor.capture(), attributeArgumentCaptor.capture()); //check entityId assertEquals("S1", entityIdArgumentCaptor.getValue().getId()); assertEquals("TempSensor", entityIdArgumentCaptor.getValue().getType()); assertFalse(entityIdArgumentCaptor.getValue().getIsPattern()); //check attributes assertEquals(2, attributeArgumentCaptor.getValue().size()); assertTrue(attributeArgumentCaptor.getValue().contains("temp")); assertTrue(attributeArgumentCaptor.getValue().contains("pressure")); //check ListenableFuture is called never and with addCallback method verify(updateContextResponseListenableFuture, never()).addCallback(any(), any()); //verify ngsiClient.updateContext is never called verify(ngsiClient, never()).updateContext(any(), any(), any()); //check ngsiClient.notify is called at least once // Capture notifyContext when postNotifyContextRequest is called on updateContextRequest, ArgumentCaptor<NotifyContext> notifyContextArg = ArgumentCaptor.forClass(NotifyContext.class); verify(notifyContextResponseListenableFuture, atLeastOnce()).addCallback(any(), any()); String urlReference = subscribeContext.getReference().toString(); verify(ngsiClient, atLeastOnce()).notifyContext(eq(urlReference), any(), notifyContextArg.capture()); // Check id and status correspond to the required assertEquals(1, notifyContextArg.getValue().getContextElementResponseList().size()); ContextElementResponse contextElementResponse = notifyContextArg.getValue().getContextElementResponseList() .get(0); assertEquals("S1", contextElementResponse.getContextElement().getEntityId().getId()); assertEquals("200", contextElementResponse.getStatusCode().getCode()); }
From source file:com.example.app.profile.ui.user.ProfileMembershipManagement.java
void doDatesEdit(@Nullable Membership membership) { if (membership == null) return;// w ww . j a v a 2 s . c o m final MembershipType membershipType = membership.getMembershipType(); assert membershipType != null; Label heading = new Label(createText(EDIT_DATES_UI_HEADING_FORMAT(), membership.getUser().getName(), membershipType.getName())); heading.setHTMLElement(HTMLElement.h3); MessageContainer messages = new MessageContainer(35_000L); PushButton saveButton = CommonActions.SAVE.push(); PushButton cancelButton = CommonActions.CANCEL.push(); RelativeOffsetRange range = new RelativeOffsetRange(5, 2); CalendarValueEditor startDateEditor = new CalendarValueEditor(START_DATE(), membership.getStartDate(), range); CalendarValueEditor endDateEditor = new CalendarValueEditor(END_DATE(), membership.getEndDate(), range); Container ui = of("edit-membership prop-wrapper prop-editor", messages, heading, of("prop-body", startDateEditor, endDateEditor), of("actions persistence-actions bottom", saveButton, cancelButton)); ActionListener closer = ev -> ui.close(); saveButton.addActionListener(ev -> { if (((Supplier<Boolean>) () -> { final Date startDate = startDateEditor.commitValue(); final Date endDate = endDateEditor.commitValue(); membership.setStartDate( convertForPersistence(toZonedDateTime(startDate, getSession().getTimeZone()))); ZonedDateTime endDateTime = toZonedDateTime(endDate, getSession().getTimeZone()); membership.setEndDate( convertForPersistence(endDateTime != null ? endDateTime.minus(1, ChronoUnit.DAYS) : null)); if (startDate != null && endDate != null && startDate.after(endDate)) { messages.sendNotification(NotificationImpl.error(ERROR_START_DATE_AFTER_END_DATE())); return false; } return true; }).get()) { closer.actionPerformed(ev); showHideConstraints(); } }); cancelButton.addActionListener(closer); getHistory().add(new HistoryElement(ui)); navigateBackOnClose(ui); }
From source file:nu.yona.server.analysis.service.ActivityServiceTest.java
private ZonedDateTime getDayStartTime(ZonedDateTime dateTime) { return dateTime.truncatedTo(ChronoUnit.DAYS); }
From source file:edu.usu.sdl.openstorefront.service.UserServiceImpl.java
@Override public void cleanupOldUserMessages() { int maxDays = Convert.toInteger(PropertiesManager.getValue(PropertiesManager.KEY_MESSAGE_KEEP_DAYS, "30")); LocalDateTime archiveTime = LocalDateTime.now(); archiveTime = archiveTime.minusDays(maxDays); archiveTime = archiveTime.truncatedTo(ChronoUnit.DAYS); String deleteQuery = "updateDts < :maxUpdateDts AND activeStatus = :activeStatusParam"; ZonedDateTime zdt = archiveTime.atZone(ZoneId.systemDefault()); Date archiveDts = Date.from(zdt.toInstant()); Map<String, Object> queryParams = new HashMap<>(); queryParams.put("maxUpdateDts", archiveDts); queryParams.put("activeStatusParam", UserMessage.INACTIVE_STATUS); persistenceService.deleteByQuery(UserMessage.class, deleteQuery, queryParams); }