List of usage examples for java.util Date after
public boolean after(Date when)
From source file:com.nridge.core.app.mgr.ServiceTimer.java
/** * Returns <i>true</i> if the time for an incremental service wake-up has * arrived.//from w w w . ja v a 2 s .co m * * @return <i>true</i> or <i>false</i> */ public boolean isTimeForIncrementalService() { boolean isTime = false; Logger appLogger = mAppMgr.getLogger(this, "isTimeForIncrementalService"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); Date tsNow = new Date(); Date tsIncrementalService = getNextTS("run_incremental_interval", getLastIncrementalServiceTS()); if (tsNow.after(tsIncrementalService)) { String msgStr = String.format("The incremental service time of '%s' has arrived.", Field.dateValueFormatted(tsIncrementalService, Field.FORMAT_DATETIME_DEFAULT)); appLogger.debug(msgStr); isTime = true; } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return isTime; }
From source file:net.big_oh.resourcestats.dao.RequestorDAO.java
public LinkedHashMap<Requestor, Number> getMostFrequentRequestors(int maxNumRequestors, Date since) throws IllegalArgumentException { // translate null parameters if (since == null) { // set an appropriate default value since = new Date(0); }// ww w. j a va 2 s . co m // sanity check for parameters if (maxNumRequestors < 1) { throw new IllegalArgumentException("Argument maxNumRequestors must not be less than 1."); } if (since.after(new Date())) { throw new IllegalArgumentException("Argument since must not be after the current system time."); } Query query = getQualifiedNamedQuery("getMostFrequentRequestors"); query.setMaxResults(maxNumRequestors); query.setDate("since", since); return processQueryResults(query.list()); }
From source file:org.openmrs.module.pihmalawi.reporting.definition.cohort.evaluator.EncounterAfterTerminalStateCohortDefinitionEvaluator.java
public EvaluatedCohort evaluate(CohortDefinition cohortDefinition, EvaluationContext context) { EncounterAfterTerminalStateCohortDefinition cd = (EncounterAfterTerminalStateCohortDefinition) cohortDefinition; Cohort c = new Cohort(); HqlQueryBuilder maxStateStart = new HqlQueryBuilder(); maxStateStart.select("ps.patientProgram.patient.patientId", "ps.patientProgram.location.locationId", "max(ps.startDate)"); maxStateStart.from(PatientState.class, "ps"); maxStateStart.wherePatientIn("ps.patientProgram.patient.patientId", context); maxStateStart.whereEqual("ps.patientProgram.program", cd.getProgram()); maxStateStart.whereIn("ps.patientProgram.location", cd.getLocations()); maxStateStart.groupBy("ps.patientProgram.patient.patientId") .groupBy("ps.patientProgram.location.locationId"); Map<Integer, Map<Integer, Date>> maxStateDates = getPatientLocationDateMap(maxStateStart, context); HqlQueryBuilder maxTerminalStart = new HqlQueryBuilder(); maxTerminalStart.select("ps.patientProgram.patient.patientId", "ps.patientProgram.location.locationId", "max(ps.startDate)"); maxTerminalStart.from(PatientState.class, "ps"); maxTerminalStart.wherePatientIn("ps.patientProgram.patient.patientId", context); maxTerminalStart.whereEqual("ps.patientProgram.program", cd.getProgram()); maxTerminalStart.whereIn("ps.patientProgram.location", cd.getLocations()); maxTerminalStart.whereEqual("ps.state.terminal", true); maxTerminalStart.groupBy("ps.patientProgram.patient.patientId") .groupBy("ps.patientProgram.location.locationId"); Map<Integer, Map<Integer, Date>> maxTerminalStateDates = getPatientLocationDateMap(maxTerminalStart, context);// w w w .j a v a2s. c o m HqlQueryBuilder encounterQuery = new HqlQueryBuilder(); encounterQuery.select("e.patient.patientId", "e.location.locationId", "max(e.encounterDatetime)"); encounterQuery.from(Encounter.class, "e"); encounterQuery.wherePatientIn("e.patient.patientId", context); encounterQuery.whereEqual("e.patient.voided", false); encounterQuery.whereIn("e.encounterType", cd.getEncounterTypes()); encounterQuery.whereIn("e.location", cd.getLocations()); encounterQuery.groupBy("e.patient.patientId").groupBy("e.location.locationId"); Map<Integer, Map<Integer, Date>> maxEncounterDates = getPatientLocationDateMap(encounterQuery, context); for (Integer pId : maxEncounterDates.keySet()) { Map<Integer, Date> encounterDateMap = maxEncounterDates.get(pId); Map<Integer, Date> maxStateDateMap = maxStateDates.get(pId); Map<Integer, Date> maxTerminalStateDateMap = maxTerminalStateDates.get(pId); for (Integer locationId : encounterDateMap.keySet()) { Date encounterDate = encounterDateMap.get(locationId); Date stateDate = (maxStateDateMap != null ? maxStateDateMap.get(locationId) : null); Date terminalDate = (maxTerminalStateDateMap != null ? maxTerminalStateDateMap.get(locationId) : null); if (terminalDate != null && encounterDate.after(terminalDate) && terminalDate.equals(stateDate)) { c.addMember(pId); } } } return new EvaluatedCohort(c, cd, context); }
From source file:com.mycompany.TFolderResource.java
public Date getMostRecentModDate() { Date latest = this.getModifiedDate(); for (Resource r : this.getChildren()) { Date d; if (r instanceof TFolderResource) { TFolderResource tf = (TFolderResource) r; d = tf.getMostRecentModDate(); } else {/* www. j a va2 s . c om*/ d = r.getModifiedDate(); } if (d != null && (latest == null || d.after(latest))) { latest = d; } } return latest; }
From source file:com.alibaba.dubbo.governance.web.common.pulltool.Tool.java
public boolean beforeNow(Date date) { Date now = new Date(); if (now.after(date)) { return true; }// w w w. j av a2s.c om return false; }
From source file:com.dagobert_engine.statistics.service.MtGoxStatisticsService.java
public void refreshPeriods() throws ParseException { synchronized (lock) { final Date NOW = new Date(); final int periodLength = config.getDefaultPeriodLength(); if (currentPeriod == null || NOW.after(currentPeriod.getToTime())) { lastPeriod = currentPeriod;/*w ww . j a v a 2 s .c o m*/ currentPeriod = new Period(); currentPeriod.setFromTime(NOW); currentPeriod.setToTime(new Date(NOW.getTime() + periodLength)); } BTCRate rate = new BTCRate(); rate.setDateTime(NOW); rate.setCurrency(config.getDefaultCurrency()); rate.setValue(getLastPrice(rate.getCurrency()).getValue()); // Add rate to current period rate.setPeriod(currentPeriod); currentPeriod.getRates().add(rate); // calculate values for period currentPeriod.setAvgRate(calcAvgForRates(currentPeriod.getRates())); currentPeriod.setLatestRate(rate); BTCRate maxRate = currentPeriod.getRates().get(calcMaxIndex(currentPeriod.getRates())); BTCRate minRate = currentPeriod.getRates().get(calcMinIndex(currentPeriod.getRates())); currentPeriod.setMaxRate(maxRate); currentPeriod.setMaxRate(minRate); currentPeriod.setStdDev(calcStdDev(currentPeriod.getRates())); currentPeriod.setPropDown(calcPropability(currentPeriod.getAvgRate(), currentPeriod.getStdDev(), PropabilityType.LESS_THAN, currentPeriod.getLatestRate().getValue())); currentPeriod.setPropUp(calcPropability(currentPeriod.getAvgRate(), currentPeriod.getStdDev(), PropabilityType.GREATER_THAN, currentPeriod.getLatestRate().getValue())); } }
From source file:net.big_oh.resourcestats.dao.ResourceDAO.java
public LinkedHashMap<Resource, Number> getMostPopularResources(int maxNumResources, Date since) throws IllegalArgumentException { // translate null parameters if (since == null) { // set an appropriate default value since = new Date(0); }/*from w ww .ja v a 2 s .com*/ // sanity check for parameters if (maxNumResources < 1) { throw new IllegalArgumentException("Argument maxNumResources must not be less than 1."); } if (since.after(new Date())) { throw new IllegalArgumentException("Argument since must not be after the current system time."); } Query query = getQualifiedNamedQuery("getMostPopularResources"); query.setMaxResults(maxNumResources); query.setDate("since", since); return processQueryResults(query.list()); }
From source file:com.dell.asm.asmcore.asmmanager.util.DeploymentValidator.java
private void checkScheduledDate(DeploymentValid deploymentValid, Deployment deployment) { // check for schedule date Date scheduleDate = deployment.getScheduleDate(); if (scheduleDate != null) { Date now = new Date(); if (now.after(scheduleDate)) { logger.error("Requested schedule date of " + scheduleDate + " is before current date of " + now + " for Deployment " + deployment.getDeploymentName()); deploymentValid.setValid(false); deploymentValid.addMessage(AsmManagerMessages.scheduleDateIsPast()); }/*from w w w. java 2 s.c o m*/ } }
From source file:pl.psnc.synat.wrdz.mdz.format.FileFormatVerifierBean.java
/** * Extracts a date from nodes matching the xpath expression in the given document. * // ww w.j av a 2s.c o m * If multiple dates match, the earliest date is returned. * * @param document * xml document to search * @param xpath * xpath expression * @return earliest matching date, or <code>null</code> if no dates were found */ private Date extractDate(Document document, String xpath) { NodeList nodes = xpath(document, xpath); DateFormat format = new SimpleDateFormat(DATE_FORMAT); Date result = null; for (int i = 0; i < nodes.getLength(); i++) { try { Date newDate = format.parse(nodes.item(i).getNodeValue()); if (result == null || result.after(newDate)) { result = newDate; } } catch (ParseException e) { logger.warn("Unparsable date retrieved from UDFR response: {}", nodes.item(i).getNodeValue()); } } return result; }
From source file:com.arpnetworking.configuration.triggers.UriTrigger.java
private boolean isLastModifiedChanged(final HttpResponse response) { final Header newLastModifiedHeader = response.getFirstHeader(HttpHeaders.LAST_MODIFIED); if (newLastModifiedHeader != null) { final Date newLastModified = DateUtils.parseDate(newLastModifiedHeader.getValue()); if (newLastModified == null) { throw new IllegalArgumentException("Invalid last modified date"); }// www . j av a2s .co m if (!_previousLastModified.isPresent() || newLastModified.after(_previousLastModified.get())) { LOGGER.debug().setMessage("Uri last modified changed").addData("uri", _uri) .addData("newLastModified", newLastModified) .addData("previousLastModified", _previousLastModified).log(); _previousLastModified = Optional.of(newLastModified); return true; } } return false; }