List of usage examples for java.util Date after
public boolean after(Date when)
From source file:net.di2e.ecdr.commons.query.rest.CDRQueryImpl.java
protected Filter getTemporalFilter(FilterBuilder filterBuilder, Date startDate, Date endDate, String type) throws UnsupportedQueryException { Filter filter = null;/*from w ww . j a v a 2 s .c o m*/ if (startDate != null || endDate != null) { if (startDate != null && endDate != null) { if (startDate.after(endDate)) { throw new UnsupportedQueryException( "Start date value [" + startDate + "] cannot be after endDate [" + endDate + "]"); } filter = filterBuilder.attribute(type).during().dates(startDate, endDate); humanReadableQueryBuilder.append(" " + SearchConstants.STARTDATE_PARAMETER + "=[" + startDate + "] " + SearchConstants.ENDDATE_PARAMETER + "=[" + endDate + "] " + SearchConstants.DATETYPE_PARAMETER + "=[" + type + "]"); } else if (startDate != null) { filter = filterBuilder.attribute(type).after().date(startDate); humanReadableQueryBuilder.append(" " + SearchConstants.STARTDATE_PARAMETER + "=[" + startDate + "] " + SearchConstants.DATETYPE_PARAMETER + "=[" + type + "]"); } else if (endDate != null) { filter = filterBuilder.attribute(type).before().date(endDate); humanReadableQueryBuilder.append(" " + SearchConstants.ENDDATE_PARAMETER + "=[" + endDate + "] " + SearchConstants.DATETYPE_PARAMETER + "=[" + type + "]"); } } return filter; }
From source file:com.sube.daos.mongodb.StatisticDaoTest.java
private void generateUsages() throws InvalidSubeCardException, InvalidProviderException { for (int i = 0; i < usagesSize; i++) { SubeCardUsage usage = new SubeCardUsage(); usage.setCard((SubeCard) getRandom(cards)); Date randomDate = DateUtils.round( DateUtils.round(DateUtils.round(getRandomDate(FROM, TO), Calendar.SECOND), Calendar.MINUTE), Calendar.HOUR);//from w w w. j a va 2 s. c o m usage.setDatetime(randomDate); if ((randomDate.after(TO_DIFF) || DateUtils.isSameDay(randomDate, TO_DIFF)) && (randomDate.before(TO) || DateUtils.isSameDay(randomDate, TO))) { Long count = usages1.get(randomDate); if (count != null) { count++; } else { count = Long.valueOf(1l); } usages1.put(randomDate, count); } else if ((randomDate.after(FROM) || DateUtils.isSameDay(randomDate, FROM)) && (randomDate.before(FROM_DIFF) || DateUtils.isSameDay(randomDate, FROM_DIFF))) { Long count = usages2.get(randomDate); if (count != null) { count++; } else { count = Long.valueOf(1l); } usages2.put(randomDate, count); } if (random.nextInt() % 2 == 0) { //Charge Money usage.setMoney((random.nextDouble() + 0.1d) * MONEY_LAMBDA); // 3.1 // max, // min // 0.1 usage.setPerformer((Provider) getRandom(cashierProviders)); cardUsagesDao.chargeMoney(usage); } else { //Charge Service usage.setMoney((random.nextDouble() + 0.1d) * -MONEY_LAMBDA); // -3.1 // min, // max // -0.1 usage.setPerformer((Provider) getRandom(serviceProviders)); cardUsagesDao.chargeService(usage); Long travelsCount = travels.get(usage.getCard()); if (travelsCount == null) { travelsCount = Long.valueOf(1l); } else { travelsCount++; } travels.put(usage.getCard(), travelsCount); } Double totalMoney = usages.get(usage.getPerformer()); if (totalMoney == null) { usages.put(usage.getPerformer(), Math.abs(usage.getMoney())); } else { totalMoney += Math.abs(usage.getMoney()); usages.put(usage.getPerformer(), totalMoney); } registerMoneyExpended(usage); } }
From source file:com.qcadoo.mes.productionPerShift.hooks.ProductionPerShiftDetailsHooks.java
private void checkOrderDates(final ViewDefinitionState view, final Entity order) { Long technologyId = order.getBelongsToField(OrderFields.TECHNOLOGY).getId(); Set<Long> progressForDayIds = productionPerShiftDataProvider.findIdsOfEffectiveProgressForDay(technologyId); DataDefinition progressForDayDD = dataDefinitionService.get(ProductionPerShiftConstants.PLUGIN_IDENTIFIER, ProductionPerShiftConstants.MODEL_PROGRESS_FOR_DAY); Optional<OrderDates> maybeOrderDates = OrderDates.of(order); boolean areDatesCorrect = true; if (maybeOrderDates.isPresent()) { OrderDates orderDates = maybeOrderDates.get(); Date orderStart = removeTime(orderDates.getStart().effectiveWithFallback().toDate()); Date orderEnd = removeTime(orderDates.getEnd().effectiveWithFallback().toDate()); for (Long id : progressForDayIds) { Entity progressForDay = progressForDayDD.get(id); Date progressDate = progressForDay.getDateField(ProgressForDayFields.ACTUAL_DATE_OF_DAY); if (progressDate == null) { progressDate = progressForDay.getDateField(ProgressForDayFields.DATE_OF_DAY); }// w w w . ja v a 2 s .c om if (progressDate.before(orderStart) || progressDate.after(orderEnd)) { areDatesCorrect = false; } } } if (!areDatesCorrect) { view.addMessage("productionPerShift.info.invalidDates", MessageType.INFO, false); } }
From source file:ch.entwine.weblounge.test.harness.content.CacheTest.java
/** * Tests if the modification date of a page can properly be adjusted by a * pagelet that is using the <code><modified></code> tag. * /* w ww.j av a 2 s . c o m*/ * @param serverUrl * the server url * @throws Exception * if the test fails */ private void testPageletModifcationDate(String serverUrl) throws Exception { logger.info("Preparing test of cache headers influenced by the 'modified' tag"); // Load the page's modification date String requestUrl = UrlUtils.concat(serverUrl, "system/weblounge/pages", modificationTestPageId); HttpGet getPageRequest = new HttpGet(requestUrl); HttpClient httpClient = new DefaultHttpClient(); Page page = null; logger.info("Requesting the page's modification date at {}", requestUrl); try { HttpResponse response = TestUtils.request(httpClient, getPageRequest, null); assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); PageReader reader = new PageReader(); page = reader.read(response.getEntity().getContent(), site); } finally { httpClient.getConnectionManager().shutdown(); } DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); df.setTimeZone(TimeZone.getTimeZone("GMT")); // Regularly load the page requestUrl = UrlUtils.concat(serverUrl, modificationTestPage); logger.info("Sending request to {}", requestUrl); HttpGet request = new HttpGet(requestUrl); request.addHeader("X-Cache-Debug", "yes"); String[][] params = new String[][] { {} }; // Send and the request and examine the response. Keep the modification // date. httpClient = new DefaultHttpClient(); try { HttpResponse response = TestUtils.request(httpClient, request, params); int statusCode = response.getStatusLine().getStatusCode(); boolean okOrNotModified = statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_NOT_MODIFIED; assertTrue(okOrNotModified); // Get the Modified header assertNotNull(response.getHeaders("Last-Modified")); assertEquals(1, response.getHeaders("Last-Modified").length); Date hostModified = df.parse(response.getHeaders("Last-Modified")[0].getValue()); response.getEntity().consumeContent(); // Make sure the page is advertised as being more recent than the page's // modification date assertTrue(hostModified.after(page.getModificationDate())); } finally { httpClient.getConnectionManager().shutdown(); } }
From source file:org.ngrinder.perftest.service.PerfTestRunnable.java
private boolean isScheduledNow(PerfTest test) { Date current = new Date(); Date scheduledDate = DateUtils.truncate((Date) defaultIfNull(test.getScheduledTime(), current), Calendar.MINUTE);//from w w w . j av a2 s . com return current.after(scheduledDate); }
From source file:com.ecyrd.jspwiki.plugin.AbstractReferralPlugin.java
/** * Filters a collection according to the include and exclude parameters. * // w w w.j av a2s . c o m * @param c The collection to filter. * @return A filtered collection. */ protected Collection filterCollection(Collection c) { ArrayList<Object> result = new ArrayList<Object>(); PatternMatcher pm = new Perl5Matcher(); for (Iterator i = c.iterator(); i.hasNext();) { String pageName = null; Object objectje = i.next(); if (objectje instanceof WikiPage) { pageName = ((WikiPage) objectje).getName(); } else { pageName = (String) objectje; } // // If include parameter exists, then by default we include only those // pages in it (excluding the ones in the exclude pattern list). // // include='*' means the same as no include. // boolean includeThis = m_include == null; if (m_include != null) { for (int j = 0; j < m_include.length; j++) { if (pm.matches(pageName, m_include[j])) { includeThis = true; break; } } } if (m_exclude != null) { for (int j = 0; j < m_exclude.length; j++) { if (pm.matches(pageName, m_exclude[j])) { includeThis = false; break; // The inner loop, continue on the next item } } } if (includeThis) { if (objectje instanceof WikiPage) { result.add(objectje); } else { result.add(pageName); } // // if we want to show the last modified date of the most recently change page, we keep a "high watermark" here: WikiPage page = null; if (m_lastModified) { page = m_engine.getPage(pageName); if (page != null) { Date lastModPage = page.getLastModified(); if (log.isDebugEnabled()) { log.debug("lastModified Date of page " + pageName + " : " + m_dateLastModified); } if (lastModPage.after(m_dateLastModified)) { m_dateLastModified = lastModPage; } } } } } return result; }
From source file:eu.europa.esig.dss.tsl.service.TSLRepository.java
public List<TSLValidationModel> getTSLValidationModels() { List<TSLValidationModel> result = new ArrayList<TSLValidationModel>(); Date now = new Date(); for (TSLValidationModel tslValidationModel : tsls.values()) { if (!allowExpiredTSLs) { TSLParserResult parseResult = tslValidationModel.getParseResult(); if (parseResult != null) { if (now.after(parseResult.getNextUpdateDate())) { continue; }/*w ww .ja v a 2 s.c o m*/ } } if (!allowInvalidSignatures) { TSLValidationResult validationResult = tslValidationModel.getValidationResult(); if (validationResult != null) { if (validationResult.isInvalid()) { continue; } } } if (!allowIndeterminateSignatures) { TSLValidationResult validationResult = tslValidationModel.getValidationResult(); if (validationResult != null) { if (validationResult.isIndeterminate()) { continue; } } } result.add(tslValidationModel); } return Collections.unmodifiableList(result); }
From source file:com.qcadoo.mes.orders.hooks.OrderHooks.java
public boolean checkOrderDates(final DataDefinition orderDD, final Entity order) { DateRange orderDateRange = orderDatesService.getCalculatedDates(order); Date dateFrom = orderDateRange.getFrom(); Date dateTo = orderDateRange.getTo(); if (dateFrom == null || dateTo == null || dateTo.after(dateFrom)) { return true; }/*from w ww. j av a2s.c o m*/ order.addError(orderDD.getField(OrderFields.FINISH_DATE), "orders.validate.global.error.datesOrder"); return false; }
From source file:de.seitenbau.govdata.edit.gui.controller.EditController.java
@RequestMapping public void submitForm(@Valid @ModelAttribute("editForm") EditForm editForm, BindingResult result, ActionResponse response, ActionRequest request) { // fix zeitbezug dates if they are in the wrong temporal order Date fromDate = parseDate(editForm.getTemporalCoverageFrom()); Date untilDate = parseDate(editForm.getTemporalCoverageUntil()); if (fromDate != null && untilDate != null && fromDate.after(untilDate)) { editForm.setTemporalCoverageFrom(formatDate(untilDate)); editForm.setTemporalCoverageUntil(formatDate(fromDate)); } else {//from ww w.j a va 2 s .c o m editForm.setTemporalCoverageFrom(formatDate(fromDate)); editForm.setTemporalCoverageUntil(formatDate(untilDate)); } // check if form is valid if (!result.hasErrors()) { try { User ckanUser = getCkanuserFromRequestProxy(request); saveDataset(editForm, ckanUser); // get the name in the same way he new name is created for new datasets if (editForm.isNewDataset()) { editForm.setName(registryClient.getInstance().mungeTitleToName(editForm.getTitle())); } // reload saved dataset, so we reflect the actual saved data editForm = loadDataset(ckanUser, editForm.getName()); response.setRenderParameter(MESSAGE_TYPE, MessageType.SUCCESS.toString()); response.setRenderParameter(MESSAGE, "od.editform.save.success"); } catch (OpenDataRegistryException | PortalException | SystemException e) { response.setRenderParameter(MESSAGE_TYPE, MessageType.ERROR.toString()); if (StringUtils.isNotEmpty(e.getMessage())) { response.setRenderParameter(MESSAGE, e.getMessage()); } else { response.setRenderParameter(MESSAGE, "od.editform.save.error"); e.printStackTrace(); // just so we can look it up... we don't know yet what's going on. } } } else { response.setRenderParameter(MESSAGE_TYPE, MessageType.WARNING.toString()); response.setRenderParameter(MESSAGE, "od.editform.save.warning"); log.warn("Form has errors: " + result.getAllErrors()); } }
From source file:com.autentia.tnt.businessobject.User.java
/** * @return Return if the user password expired *///ww w .j av a 2 s . c o m public boolean isPasswordExpired() { Date nowDate = new Date(); Date expireDate = this.getPasswordExpireDate(); boolean passExpired = (expireDate == null) || nowDate.after(expireDate); if (passExpired && log.isInfoEnabled()) { log.info("Passord expired for user " + this.getLogin()); } return passExpired; }