List of usage examples for java.util Date after
public boolean after(Date when)
From source file:org.openhealthtools.openatna.web.MessageController.java
private Query createQuery(QueryBean bean) { Query query = new Query(); if (bean.getEventIdCode() != null && bean.getEventIdCode().length() > 0) { query.addConditional(Query.Conditional.EQUALS, bean.getEventIdCode(), Query.Target.EVENT_ID_CODE); }/* w w w . ja v a 2 s .c o m*/ if (bean.getEventOutcome() != null && bean.getEventOutcome().length() > 0) { query.addConditional(Query.Conditional.EQUALS, Integer.parseInt(bean.getEventOutcome()), Query.Target.EVENT_OUTCOME); } if (bean.getObjectId() != null && bean.getObjectId().length() > 0) { query.addConditional(getConditionalForString(bean.getObjectId()), convertStars(bean.getObjectId()), Query.Target.OBJECT_ID); } if (bean.getSourceId() != null && bean.getSourceId().length() > 0) { query.addConditional(getConditionalForString(bean.getSourceId()), convertStars(bean.getSourceId()), Query.Target.SOURCE_ID); } if (bean.getParticipantTypeCode() != null && bean.getParticipantTypeCode().length() > 0) { query.addConditional(getConditionalForString(bean.getParticipantTypeCode()), convertStars(bean.getParticipantTypeCode()), Query.Target.PARTICIPANT_TYPE_CODE); } if (bean.getSourceTypeCode() != null && bean.getSourceTypeCode().length() > 0) { query.addConditional(getConditionalForString(bean.getSourceTypeCode()), convertStars(bean.getSourceTypeCode()), Query.Target.SOURCE_TYPE_CODE); } if (bean.getObjectTypeCode() != null && bean.getObjectTypeCode().length() > 0) { query.addConditional(getConditionalForString(bean.getObjectTypeCode()), convertStars(bean.getObjectTypeCode()), Query.Target.OBJECT_TYPE_CODE); } if (bean.getParticipantId() != null && bean.getParticipantId().length() > 0) { query.addConditional(getConditionalForString(bean.getParticipantId()), convertStars(bean.getParticipantId()), Query.Target.PARTICIPANT_ID); } if (bean.getEventAction() != null && bean.getEventAction().length() > 0) { query.addConditional(Query.Conditional.EQUALS, bean.getEventAction(), Query.Target.EVENT_ACTION); } if (bean.getEventTime() != null && bean.getEventTime().length() > 0) { Date ts = Timestamp.parseToDate(bean.getEventTime()); if (ts != null) { query.addConditional(Query.Conditional.EQUALS, ts, Query.Target.EVENT_TIME); } } Date startDate = null; if (bean.getStartDate() != null && bean.getStartDate().length() > 0) { String date = bean.getStartDate(); try { startDate = format.parse(date + " " + bean.getStartHour() + ":" + bean.getStartMin()); query.after(startDate); } catch (ParseException e) { } } if (bean.getEndDate() != null && bean.getEndDate().length() > 0) { String date = bean.getEndDate(); try { Date dt = format.parse(date + " " + bean.getEndHour() + ":" + bean.getEndMin()); if (startDate != null) { if (dt.after(startDate)) { query.before(dt); } } else { query.before(dt); } } catch (ParseException e) { } } if (bean.getEventTypeCode() != null && bean.getEventTypeCode().length() > 0) { query.addConditional(Query.Conditional.EQUALS, bean.getEventTypeCode(), Query.Target.EVENT_TYPE_CODE); } if (bean.getSourceAddress() != null && bean.getSourceAddress().length() > 0) { query.addConditional(Query.Conditional.EQUALS, bean.getSourceAddress(), Query.Target.SOURCE_ADDRESS); } query.setMaxResults(bean.getMaxResults()); query.setStartOffset(bean.getStartOffset()); query.orderAscending(Query.Target.ID); return query; }
From source file:org.starfishrespect.myconsumption.server.business.sensors.flukso.FluksoRetriever.java
/** * Tries to retrieve data available for the sensor in a given interval * * @param startTime Start of the interval * @param endTime End of the interval. Must be higher of equal than startTime, and lower than actual time * @return the retrieved data//from w w w . ja va2 s . c o m * @throws RetrieveException if any error occurs */ @Override public SensorData getData(Date startTime, Date endTime) throws RetrieveException { if (startTime.after(endTime)) { throw new RequestException(0, "Start Time must be lower than end time"); } // cut data in day interval and retrieve with minute precision SensorData data = new SensorData(); long now = Calendar.getInstance().getTimeInMillis(); // last day Date currentComparisonDate = new Date(now - 86400000L); if (endTime.after(currentComparisonDate)) { if (startTime.after(currentComparisonDate)) { data.append(retrieve(startTime, endTime, maximumResolution(endTime))); } else { data.append(retrieve(currentComparisonDate, endTime, maximumResolution(endTime))); } endTime = currentComparisonDate; } if (endTime.before(startTime)) { return data; } // last week currentComparisonDate = new Date(now - 604800000L); if (endTime.after(currentComparisonDate)) { if (startTime.after(currentComparisonDate)) { data.append(retrieve(startTime, endTime, maximumResolution(endTime))); } else { data.append(retrieve(currentComparisonDate, endTime, maximumResolution(endTime))); } endTime = currentComparisonDate; } if (endTime.before(startTime)) { return data; } // last year currentComparisonDate = new Date(now - 31536000000L); if (endTime.after(currentComparisonDate)) { if (startTime.after(currentComparisonDate)) { data.append(retrieve(startTime, endTime, maximumResolution(endTime))); } else { data.append(retrieve(currentComparisonDate, endTime, maximumResolution(endTime))); } endTime = currentComparisonDate; } if (endTime.before(startTime)) { return data; } // retrieve annual values while (startTime.before(endTime)) { currentComparisonDate = new Date(endTime.getTime() - 31536000000L); if (startTime.after(currentComparisonDate)) { data.append(retrieve(startTime, endTime, maximumResolution(endTime))); } else { data.append(retrieve(currentComparisonDate, endTime, maximumResolution(endTime))); } endTime = currentComparisonDate; if (!data.mayHaveMoreData()) { break; } } return data; }
From source file:com.wso2telco.gsma.authenticators.attributeshare.AbstractAttributeShare.java
private boolean isLongLiveConsent(AuthenticationContext context, String scope) throws NamingException, DBUtilException { boolean isConsent = false; try {//from w w w. ja v a 2 s .c o m UserConsentDetails userConsentDetails = getUserConsentDetails(context, scope); if (userConsentDetails == null) { isConsent = true; } else { if (userConsentDetails.getRevokeStatus().equalsIgnoreCase(Constants.TRUE)) { Date today = new Date(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); if (today.after(dateFormat.parse(userConsentDetails.getConsentExpireDatetime()))) { isConsent = true; } } else if (userConsentDetails.getRevokeStatus().equalsIgnoreCase(Constants.FALSE)) { isConsent = true; } } } catch (DBUtilException | NamingException e) { log.error("error occurred while accessing the database table : " + e.getMessage()); } catch (ParseException e) { log.error("error occurred while formatting the date : " + e.getMessage()); } return isConsent; }
From source file:ch.entwine.weblounge.cache.impl.handle.CacheHandleImpl.java
/** * {@inheritDoc}/*from ww w . ja v a 2 s. com*/ * * @see ch.entwine.weblounge.common.request.CacheHandle#setModificationDate(Date) */ @Override public Date setModificationDate(Date modificationDate) { this.modificationDate = modificationDate.after(this.modificationDate) ? modificationDate : this.modificationDate; return this.modificationDate; }
From source file:com.sap.dirigible.ide.publish.AbstractPublisher.java
protected void copyFileInto(IFile file, ICollection target, String user) throws IOException, CoreException { final com.sap.dirigible.repository.api.IResource targetResource = target.getResource(file.getName()); if (!checkOverridePermissionsForResource(file.getName(), user, targetResource)) { return;/*from www .j a v a2 s . c om*/ } com.sap.dirigible.repository.api.IResource resource = target.getRepository() .getResource(file.getWorkspace().getRoot().getRawLocation() + file.getFullPath().toString()); if (targetResource.exists()) { Date targetResourceLastModifiedAt = targetResource.getInformation().getModifiedAt(); Date resourceLastModifiedAt = resource.getInformation().getModifiedAt(); if (resourceLastModifiedAt.after(targetResourceLastModifiedAt)) { setTargetResourceContent(file, targetResource, resource); } } else { setTargetResourceContent(file, targetResource, resource); } }
From source file:fr.cph.stock.controller.portfolio.PortfolioController.java
@RequestMapping(value = "/performance", method = RequestMethod.GET) public ModelAndView performance( @RequestParam(value = FROM, required = false) @DateTimeFormat(pattern = DATE_FORMAT) final Date fromDate, @RequestParam(value = TO, required = false) @DateTimeFormat(pattern = DATE_FORMAT) final Date toDate, @Valid @ModelAttribute final User user, @CookieValue(LANGUAGE) final String lang) throws ServletException, ParseException { final ModelAndView model = new ModelAndView("performance"); try {/*from w w w . j ava 2s . co m*/ final Portfolio portfolio = userService.getUserPortfolio(user.getId(), fromDate, toDate) .orElseThrow(() -> new NotFoundException(user.getId())); if (portfolio.getShareValues().size() != 0) { Date from = portfolio.getShareValues().get(portfolio.getShareValues().size() - 1).getDate(); // Reset time to 17:00PM to get also the cac40 into the day selected (or it would not select it from = Util.resetHourMinSecMill(from); // Put 17:00PM to the first sharevalue, to make it nice in graphic portfolio.getShareValues().get(portfolio.getShareValues().size() - 1).setDate(from); // FIXME that should be done already into get user portfolio. To verify. final List<Index> indexesCAC40 = indexService.getIndexes(Constants.CAC_40, from, toDate); final List<Index> indexesSP500 = indexService.getIndexes(Constants.SP_500, from, toDate); portfolio.addIndexes(indexesCAC40); portfolio.addIndexes(indexesSP500); portfolio.compute(); Date fro = from; if (indexesCAC40.size() > 0) { final Date date = indexesCAC40.get(0).getDate(); if (date.before(fro)) { fro = date; } } if (indexesSP500.size() > 0) { final Date date2 = indexesSP500.get(0).getDate(); if (date2.before(fro)) { fro = date2; } } Date t = portfolio.getShareValues().get(0).getDate(); if (indexesCAC40.size() > 1) { final Date date3 = indexesCAC40.get(indexesCAC40.size() - 1).getDate(); if (date3.after(t)) { t = date3; } } if (indexesSP500.size() > 1) { final Date date = indexesSP500.get(indexesSP500.size() - 1).getDate(); if (date.after(t)) { t = date; } } model.addObject(FROM_UNDERSCORE, fro); model.addObject(TO_UNDERSCORE, t); } model.addObject(PORTFOLIO, portfolio); } catch (final YahooException e) { log.error("Error: {}", e.getMessage(), e); } model.addObject(LANGUAGE, LanguageFactory.INSTANCE.getLanguage(lang)); model.addObject(APP_TITLE, appProperties.getName() + " • Performance"); return model; }
From source file:com.evolveum.midpoint.task.quartzimpl.CleanupTest.java
@Test public void testTasksCleanup() throws Exception { // GIVEN//from ww w.j a va 2s .co m final File file = new File(FOLDER_REPO, "tasks-for-cleanup.xml"); List<PrismObject<? extends Objectable>> elements = prismContext.parseObjects(file); OperationResult result = new OperationResult("tasks cleanup"); for (int i = 0; i < elements.size(); i++) { PrismObject object = elements.get(i); String oid = repositoryService.addObject(object, null, result); AssertJUnit.assertTrue(StringUtils.isNotEmpty(oid)); } // WHEN // because now we can't move system time (we're not using DI for it) we create policy // which should always point to 2013-05-07T12:00:00.000+02:00 final long NOW = System.currentTimeMillis(); Calendar when = create_2013_07_12_12_00_Calendar(); CleanupPolicyType policy = createPolicy(when, NOW); taskManager.cleanupTasks(policy, taskManager.createTaskInstance(), result); // THEN List<PrismObject<TaskType>> tasks = repositoryService.searchObjects(TaskType.class, null, null, result); AssertJUnit.assertNotNull(tasks); display("tasks", tasks); AssertJUnit.assertEquals(1, tasks.size()); PrismObject<TaskType> task = tasks.get(0); XMLGregorianCalendar timestamp = task.getPropertyRealValue(TaskType.F_COMPLETION_TIMESTAMP, XMLGregorianCalendar.class); Date finished = XMLGregorianCalendarType.asDate(timestamp); Date mark = new Date(NOW); Duration duration = policy.getMaxAge(); duration.addTo(mark); AssertJUnit.assertTrue("finished: " + finished + ", mark: " + mark, finished.after(mark)); }
From source file:net.diogobohm.timed.impl.ui.overviewwindow.OverviewWindowController.java
private ActionListener createForwardPeriodAction() { return new ActionListener() { @Override//from w ww . j a va 2 s . c o m public void actionPerformed(ActionEvent e) { Date today = new Date(); Date curStartDate = getModel().getStartDate(); Date curEndDate = getModel().getEndDate(); Date newStartDate = DateUtils.addDays(curEndDate, 1); Date newEndDate = new Date( newStartDate.getTime() + (curEndDate.getTime() - curStartDate.getTime())); if (newStartDate.after(today)) { return; } Overview overview = fetchOverviewFor(newStartDate, newEndDate); getModel().setDomainBean(getView(), overview); getModel().setDates(newStartDate, newEndDate); } }; }
From source file:com.huateng.ebank.framework.util.DateUtil.java
/** /*from w w w. j av a 2s . c om*/ * 30? * @param * @return */ public static int getDaysBetween30(Date startDate, Date endDate) { Calendar calendarStartDate = Calendar.getInstance(); Calendar calendarEndDate = Calendar.getInstance(); // calendarStartDate.setTime(startDate); calendarEndDate.setTime(endDate); if (startDate.after(endDate)) { Calendar swap = calendarStartDate; calendarStartDate = calendarEndDate; calendarEndDate = swap; } int months = calendarEndDate.get(Calendar.MONTH) - calendarStartDate.get(Calendar.MONTH) + (calendarEndDate.get(Calendar.YEAR) - calendarStartDate.get(Calendar.YEAR)) * 12; Date newEndDate = getEndDateByMonths(startDate, months); if (newEndDate.compareTo(endDate) <= 0 || isSameDate(newEndDate, endDate) == true) months += 1; int days = (months - 1) * 30; Date newStartDate = getEndDateByMonths(startDate, months - 1); days += getDaysBetween(newStartDate, endDate); return days; }
From source file:org.gaixie.micrite.security.service.impl.UserServiceImpl.java
public User findByTokenKey(String key) throws SecurityException { Token token = tokenDAO.findByKey(key); if (token == null) throw new SecurityException("forgotPassword.step2.tokenNotAvailable"); Date date = new Date(); if (date.after(token.getExpireTime())) throw new SecurityException("forgotPassword.step2.tokenNotAvailable"); return token.getUser(); }