List of usage examples for java.util Date before
public boolean before(Date when)
From source file:org.openmrs.module.appointmentscheduling.api.db.hibernate.HibernateAppointmentDAO.java
@Override @Transactional(readOnly = true)//w w w . j ava 2 s.co m public List<Appointment> getAppointmentsByConstraints(Date fromDate, Date toDate, Provider provider, AppointmentType appointmentType, AppointmentStatus status) throws APIException { if (fromDate != null && toDate != null && !fromDate.before(toDate)) throw new APIException("fromDate can not be later than toDate"); else { String stringQuery = "SELECT appointment FROM Appointment AS appointment WHERE appointment.voided = 0"; if (fromDate != null) stringQuery += " AND appointment.timeSlot.startDate >= :fromDate"; if (toDate != null) stringQuery += " AND appointment.timeSlot.endDate <= :endDate"; if (provider != null) stringQuery += " AND appointment.timeSlot.appointmentBlock.provider = :provider"; if (status != null) stringQuery += " AND appointment.status=:status"; if (appointmentType != null) stringQuery += " AND appointment.appointmentType=:appointmentType"; Query query = super.sessionFactory.getCurrentSession().createQuery(stringQuery); if (fromDate != null) query.setParameter("fromDate", fromDate); if (toDate != null) query.setParameter("endDate", toDate); if (provider != null) query.setParameter("provider", provider); if (status != null) query.setParameter("status", status); if (appointmentType != null) query.setParameter("appointmentType", appointmentType); return query.list(); } }
From source file:edu.stanford.muse.email.Filter.java
public boolean matchesDate(DatedDocument dd) { if (startDate != null && endDate != null) { Date d = dd.getDate(); if (d == null) return false; if (d.before(startDate) || d.after(endDate)) return false; }/* ww w .j av a 2s . c o m*/ return true; }
From source file:org.apigw.authserver.svc.impl.ResidentServicesImpl.java
@Override public boolean validateLegalGuardian(String legalGuardianResidentIdentificationNumber, String childResidentIdentificationNumber) throws IllegalArgumentException { log.debug("validateLegalGuardian"); if (!RESIDENT_ID_PATTERN.matcher(legalGuardianResidentIdentificationNumber).matches()) { log.debug("legalGuardianResidentIdentificationNumber doesn't match pattern {}", RESIDENT_ID_PATTERN_REGEX); throw new IllegalArgumentException( "legalGuardianResidentIdentificationNumber doesn't match pattern " + RESIDENT_ID_PATTERN_REGEX); }// w ww.j ava 2 s . c om if (!RESIDENT_ID_PATTERN.matcher(childResidentIdentificationNumber).matches()) { log.debug("childResidentIdentificationNumber doesn't match pattern {}", RESIDENT_ID_PATTERN_REGEX); throw new IllegalArgumentException( "childResidentIdentificationNumber doesn't match pattern " + RESIDENT_ID_PATTERN_REGEX); } if (isOverAgeLimit(childResidentIdentificationNumber)) { log.debug("childResidentIdentificationNumber doesn't pass the ageLimit of {}", legalGuradianAgeLimit); return false; } LookupResidentForFullProfileType params = new LookupResidentForFullProfileType(); params.getPersonId().add(legalGuardianResidentIdentificationNumber); // LookUpSpecificationType spec = new LookUpSpecificationType(); // params.setLookUpSpecification(spec); LookupResidentForFullProfileResponseType response = lookupResidentForFullProfileClient .lookupResidentForFullProfile(lookupResidentForFullProfileLogicalAddress, params); if (response.getResident() == null || response.getResident().size() == 0) { log.warn( "A person with residentIdentificationNumber: {} wasn't found in the LookupResidentForFullProfile service."); return false; } boolean legalGuardianIsValid = false; SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); Date now = new Date(); for (ResidentType resident : response.getResident()) { if (resident.getPersonpost() != null && resident.getPersonpost().getRelationer() != null) { for (Relation relation : resident.getPersonpost().getRelationer().getRelation()) { if (relation.getRelationstyp() == RelationstypTYPE.V) { log.debug("Found relation type V"); try { if (relation.getRelationFromdatum() != null) { log.debug("Found relation from date {}", relation.getRelationFromdatum()); Date from = df.parse(relation.getRelationFromdatum()); if (from.after(now)) { log.debug("This relation has not reached the from date, continuing..."); continue; } } if (relation.getRelationTomdatum() != null) { log.debug("Found relation tom date {}", relation.getRelationTomdatum()); Date until = df.parse(relation.getRelationTomdatum()); if (until.before(now)) { log.debug("This relation has passed the until date, continuing..."); continue; } } } catch (ParseException e) { log.error( "ParseException while parsing from {} or until {} date, skipping this relation and continues...", relation.getRelationFromdatum(), relation.getRelationTomdatum()); continue; } if (relation.getAvregistrering() != null) { log.debug("This relation has been unregistered, continuing..."); continue; } if (relation.getStatus() == RelationStatusTYPE.AS || relation.getStatus() == RelationStatusTYPE.AV || relation.getStatus() == RelationStatusTYPE.IV || relation.getStatus() == RelationStatusTYPE.AN) { log.debug("This relation has status {}, continuing...", relation.getStatus()); } if (relation.getRelationId() != null && !StringUtils.isBlank(relation.getRelationId().getPersonNr()) && childResidentIdentificationNumber .equals(relation.getRelationId().getPersonNr())) { log.debug("Found matching relation with relation type V"); legalGuardianIsValid = true; break; } log.debug("This V relation didn't match"); } else { log.debug("Found non V relation type: {}, continuing", relation.getRelationstyp()); continue; } } } if (legalGuardianIsValid) { break; } } log.debug("validateLegalGuardian(legalGuardianResidentIdentificationNumber:NOT_LOGGED, " + "childResidentIdentificationNumber:NOT_LOGGED) returns: {}", legalGuardianIsValid); return legalGuardianIsValid; }
From source file:com.netflix.genie.common.model.Auditable.java
/** * Set the created timestamp. This is a No-Op. Set once by system. * * @param created The created timestamp/*from w ww . j a v a2 s .co m*/ */ public void setCreated(final Date created) { LOG.debug("Tried to set created to " + created + " for entity " + this.id + ". Will not be persisted."); if (created.before(this.created)) { this.created = new Date(created.getTime()); } }
From source file:com.inmobi.databus.readers.TestDatabusEmptyFolders.java
private void createMoreEmptyFolders() throws IOException { Calendar cl = Calendar.getInstance(); cl.add(Calendar.MINUTE, -25); Date startDate = cl.getTime(); cl = Calendar.getInstance();/* w ww .j ava 2s. c o m*/ cl.add(Calendar.MINUTE, -5); Date endDate = cl.getTime(); while (startDate.before(endDate)) { Path baseDir = DatabusUtil.getStreamDir(StreamType.LOCAL, new Path(cluster.getRootDir()), testStream); Path minDir = DatabusStreamReader.getMinuteDirPath(baseDir, startDate); fs.mkdirs(minDir); Calendar instance = Calendar.getInstance(); instance.setTime(startDate); instance.add(Calendar.MINUTE, 1); startDate = instance.getTime(); } }
From source file:com.gistlabs.mechanize.cache.inMemory.InMemoryCacheEntry.java
@Override public boolean isValid() { boolean mustNotCache = has("Pragma", "no-cache", this.response) || has("Cache-Control", "no-cache", this.response); if (mustNotCache) return false; Date now = new Date(); Date cacheControl = getCacheControlExpiresDate(); Date expires = getExpiresDate(); return now.before(cacheControl) || now.before(expires); }
From source file:de.hybris.platform.b2bacceleratoraddon.controllers.pages.MyQuotesController.java
@RequestMapping(value = "/quote/quoteOrderDecision") @RequireHardLogIn/*from ww w.j a va2 s . c om*/ public String quoteOrderDecision(@ModelAttribute("quoteOrderDecisionForm") final QuoteOrderForm quoteOrderForm, final Model model, final RedirectAttributes redirectModel) throws CMSItemNotFoundException { storeCmsPageInModel(model, getContentPageForLabelOrId(MY_QUOTES_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(MY_QUOTES_CMS_PAGE)); String orderCode = null; try { orderCode = quoteOrderForm.getOrderCode(); final String comment = XSSFilterUtil.filter(quoteOrderForm.getComments()); if (NEGOTIATEQUOTE.equals(quoteOrderForm.getSelectedQuoteDecision())) { if (StringUtils.isBlank(comment)) { setUpCommentIsEmptyError(quoteOrderForm, model); return quotesDetails(orderCode, model); } orderFacade.createAndSetNewOrderFromNegotiateQuote(orderCode, comment); } if (ACCEPTQUOTE.equals(quoteOrderForm.getSelectedQuoteDecision())) { final OrderData orderDetails = orderFacade.getOrderDetailsForCode(orderCode); final Date quoteExpirationDate = orderDetails.getQuoteExpirationDate(); if (quoteExpirationDate != null && quoteExpirationDate.before(new Date())) { GlobalMessages.addErrorMessage(model, "text.quote.expired"); return quotesDetails(orderCode, model); } orderFacade.createAndSetNewOrderFromApprovedQuote(orderCode, comment); return REDIRECT_PREFIX + "/checkout/orderConfirmation/" + orderCode; } if (CANCELQUOTE.equals(quoteOrderForm.getSelectedQuoteDecision())) { orderFacade.cancelOrder(orderCode, comment); } if (ADDADDITIONALCOMMENT.equals(quoteOrderForm.getSelectedQuoteDecision())) { if (StringUtils.isBlank(comment)) { setUpCommentIsEmptyError(quoteOrderForm, model); return quotesDetails(orderCode, model); } orderFacade.addAdditionalComment(orderCode, comment); GlobalMessages.addFlashMessage(redirectModel, GlobalMessages.CONF_MESSAGES_HOLDER, "text.confirmation.quote.comment.added"); return String.format(REDIRECT_TO_QUOTES_DETAILS, orderCode); } } catch (final UnknownIdentifierException e) { LOG.warn("Attempted to load a order that does not exist or is not visible", e); return REDIRECT_MY_ACCOUNT; } return REDIRECT_PREFIX + "/checkout/quote/orderConfirmation/" + orderCode; }
From source file:org.mashupmedia.service.LibraryUpdateManagerImpl.java
@Override public void updateLibrary(Library library) { library = libraryManager.getLibrary(library.getId()); if (!library.isEnabled()) { logger.info("Library is disabled, will not update:" + library.toString()); return;/* w w w.j av a 2s. c o m*/ } Date lastUpdated = library.getUpdatedOn(); Date date = new Date(); date = DateUtils.addHours(date, -LIBRARY_UPDATE_TIMEOUT_HOURS); if (library.getLibraryStatusType() == LibraryStatusType.WORKING && date.before(lastUpdated)) { logger.info("Library is already updating, exiting:" + library.toString()); return; } try { library.setLibraryStatusType(LibraryStatusType.WORKING); libraryManager.saveLibrary(library); Location location = library.getLocation(); File folder = new File(location.getPath()); if (!folder.isDirectory()) { logger.error("Media library points to a file not a directory, exiting..."); return; } processLibrary(library); library.setLibraryStatusType(LibraryStatusType.OK); } catch (Exception e) { logger.error("Error updating library", e); library.setLibraryStatusType(LibraryStatusType.ERROR); } finally { libraryManager.saveLibrary(library); } }
From source file:be.fedict.trust.service.bean.ValidationServiceBean.java
public Date validate(BigInteger serialNumber, byte[] issuerNameHash, byte[] issuerKeyHash) { LOG.debug("validate"); Date unknownRevocationDate = new Date(); CertificateAuthorityEntity certificateAuthority = this.certificateAuthorityLookupBean.lookup(issuerNameHash, issuerKeyHash);// w w w. j a v a2 s. c o m if (null == certificateAuthority) { LOG.error("no certificate authority found"); return unknownRevocationDate; } String caName = certificateAuthority.getName(); LOG.debug("CA: " + caName); Date thisUpdate = certificateAuthority.getThisUpdate(); Date nextUpdate = certificateAuthority.getNextUpdate(); Date validationDate = new Date(); if (Status.ACTIVE != certificateAuthority.getStatus()) { LOG.debug("CRL cache not active for CA: " + caName); return unknownRevocationDate; } if (null == thisUpdate || validationDate.before(thisUpdate)) { LOG.debug("validation date before this update: " + caName); return unknownRevocationDate; } if (null == nextUpdate || validationDate.after(nextUpdate)) { LOG.debug("validation date after next update: " + caName); return unknownRevocationDate; } RevokedCertificateEntity revokedCertificate = this.entityManager.find(RevokedCertificateEntity.class, new RevokedCertificatePK(caName, serialNumber.toString())); if (null == revokedCertificate) { return null; } LOG.debug("revoked certificate: " + caName + " " + serialNumber); return revokedCertificate.getRevocationDate(); }
From source file:it.geosolutions.opensdi2.userexpiring.ExpiringUpdater.java
/** * Check if the user is expired. parsing the expire attribute * //w ww . j a v a 2 s . c o m * @param u * the user to check */ private boolean checkExpired(User u) { List<UserAttribute> al = u.getAttribute(); if (al != null) { for (UserAttribute a : al) { if (attributeName.equals(a.getName())) { if (LOGGER.isInfoEnabled()) { LOGGER.info("User:"); LOGGER.info(u.getName()); LOGGER.info("expiring date:"); LOGGER.info(a.getValue()); } try { Date date = formatter.parse(a.getValue()); LOGGER.info("expiring date parsed as:" + date); if (date.before(new Date())) { LOGGER.info("user is expired"); return true; } else { LOGGER.info("user is not expired"); return false; } } catch (ParseException e) { LOGGER.warn("the date is not well formatted. skipping"); } } } } return false; }