List of usage examples for java.util Date after
public boolean after(Date when)
From source file:edu.wisc.my.stats.web.command.validation.QueryCommandValidator.java
private void validateDates(QueryCommand queryCommand, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "queryParameters.start", "portlet.queryinfo.error.start.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "queryParameters.end", "portlet.queryinfo.error.end.required"); final QueryParameters queryParameters = queryCommand.getQueryParameters(); final Date start = queryParameters.getStart(); final Date end = queryParameters.getEnd(); if (start != null && end != null && start.after(end)) { errors.rejectValue("queryParameters.start", "portlet.queryinfo.error.start.greater_than_end"); }//from w w w .j av a 2 s. c o m }
From source file:org.commonjava.indy.ftest.core.content.RemoteRepoTimeoutDisablesStoreAndShowsInDisabledTimeoutsMapTest.java
@Test public void run() throws Exception { final String repo1 = "repo1"; final String path = "org/foo/bar/maven-metadata.xml"; server.expect(server.formatUrl(repo1, path), 200, new DelayInputStream()); RemoteRepository remote1 = new RemoteRepository(repo1, server.formatUrl(repo1)); remote1.setMetadata(Location.CONNECTION_TIMEOUT_SECONDS, Integer.toString(1)); remote1 = client.stores().create(remote1, "adding remote", RemoteRepository.class); try (InputStream is = client.content().get(remote, repo1, path)) { } catch (final IndyClientException e) { assertThat(e.getStatusCode(), equalTo(HttpStatus.SC_BAD_GATEWAY)); }// w ww.ja va 2s . c o m Thread.sleep(1000); RemoteRepository result = client.stores().load(remote, repo1, RemoteRepository.class); assertThat(result.isDisabled(), equalTo(true)); Map<StoreKey, Date> storeTimeouts = client.schedules().getDisabledStoreTimeouts(); Date timeout = storeTimeouts.get(new StoreKey(remote, repo1)); assertThat(timeout, notNullValue()); assertThat(timeout.after(new Date()), equalTo(true)); }
From source file:org.openmrs.module.radiology.order.RadiologyOrderValidator.java
private void validateDateActivated(Order order, Errors errors) { final Date dateActivated = order.getDateActivated(); if (dateActivated != null) { if (dateActivated.after(new Date())) { errors.rejectValue("dateActivated", "Order.error.dateActivatedInFuture"); return; }/* w w w .ja v a 2 s . com*/ final Date dateStopped = order.getDateStopped(); if (dateStopped != null && dateActivated.after(dateStopped)) { errors.rejectValue("dateActivated", "Order.error.dateActivatedAfterDiscontinuedDate"); errors.rejectValue("dateStopped", "Order.error.dateActivatedAfterDiscontinuedDate"); } final Date autoExpireDate = order.getAutoExpireDate(); if (autoExpireDate != null && dateActivated.after(autoExpireDate)) { errors.rejectValue("dateActivated", "Order.error.dateActivatedAfterAutoExpireDate"); errors.rejectValue("autoExpireDate", "Order.error.dateActivatedAfterAutoExpireDate"); } final Encounter encounter = order.getEncounter(); if (encounter != null && encounter.getEncounterDatetime() != null && encounter.getEncounterDatetime().after(dateActivated)) { errors.rejectValue("dateActivated", "Order.error.dateActivatedAfterEncounterDatetime"); } } }
From source file:com.esofthead.mycollab.module.tracker.domain.SimpleBug.java
public boolean isOverdue() { if (BugStatus.Verified.name().equals(getStatus())) { return false; }//from ww w. j av a2 s . com if (this.getDuedate() != null) { Calendar today = Calendar.getInstance(); today.set(Calendar.HOUR_OF_DAY, 0); Date todayDate = today.getTime(); return todayDate.after(this.getDuedate()); } else { return false; } }
From source file:fr.pasteque.client.models.Discount.java
public boolean isValid() { if (endDate.before(startDate)) Log.w(LOG_TAG, "Corrupted Discount, endDate is anterior to startDate"); Date now = Calendar.getInstance().getTime(); return now.after(startDate) && now.before(endDate); }
From source file:in.bbat.license.LicenseInfo.java
public boolean isExpired() { Date localDate = new Date(); return localDate.after(this.expiryDate); }
From source file:org.jasig.schedassist.impl.events.ReminderServiceApplicationListener.java
@Async @Override/*w w w . j a va2 s. com*/ public void onApplicationEvent(AbstractAppointmentEvent event) { final IScheduleOwner owner = event.getOwner(); final Reminders reminderPreference = owner.getRemindersPreference(); if (reminderPreference.isEnabled()) { if (event instanceof AppointmentCreatedEvent || event instanceof AppointmentJoinedEvent) { final Date sendTime = DateUtils.addHours(event.getBlock().getStartTime(), -reminderPreference.getHours()); if (sendTime.after(new Date())) { // only create the reminder if and only if the "sendTime" is in the future this.reminderService.createEventReminder(event.getOwner(), event.getVisitor().getCalendarAccount(), event.getBlock(), event.getEvent(), sendTime); } } else if (event instanceof AppointmentCancelledEvent || event instanceof AppointmentLeftEvent) { final IReminder reminder = this.reminderService.getReminder(owner, event.getVisitor().getCalendarAccount(), event.getBlock()); if (reminder != null) { this.reminderService.deleteEventReminder(reminder); } } } }
From source file:com.vmware.identity.openidconnect.server.SolutionUserAuthenticator.java
private SolutionUser retrieveSolutionUser(String tenant, String certSubjectDn) throws ServerException { com.vmware.identity.idm.SolutionUser idmSolutionUser; try {/*w w w . ja va2 s . com*/ idmSolutionUser = this.idmClient.findSolutionUserByCertDn(tenant, certSubjectDn); } catch (Exception e) { throw new ServerException(ErrorObject.serverError("idm error while retrieving solution user"), e); } if (idmSolutionUser == null || idmSolutionUser.getId() == null || idmSolutionUser.getCert() == null) { throw new ServerException( ErrorObject.invalidRequest("solution user with specified cert subject dn not found")); } if (idmSolutionUser.isDisabled()) { throw new ServerException(ErrorObject.accessDenied("solution user has been disabled or deleted")); } Date now = new Date(); if (now.before(idmSolutionUser.getCert().getNotBefore()) || now.after(idmSolutionUser.getCert().getNotAfter())) { throw new ServerException(ErrorObject.accessDenied("cert has expired")); } return new SolutionUser(idmSolutionUser.getId(), tenant, idmSolutionUser.getCert()); }
From source file:net.firejack.platform.service.authority.broker.ResetPasswordBroker.java
@Override protected ServiceResponse perform(ServiceRequest<NamedValues<String>> request) throws Exception { ServiceResponse response;//from w w w . ja va2 s.c o m try { String token = request.getData().get(PARAM_TOKEN); String cryptKey = token.substring(0, 8); String encryptedToken = token.substring(32); String tokenDate = SecurityUtils.decryptData(encryptedToken, cryptKey); Date date = ForgotPasswordBroker.DATE_TOKEN_FORMAT.parse(tokenDate); date = DateUtils.addDays(date, 1); if (date.after(new Date())) { UserModel userModel = userStore.findUserByToken(token); if (userModel != null) { String newPassword = SecurityHelper.generateRandomSequence(8); String hashPassword = SecurityHelper.hash(newPassword); userModel.setPassword(hashPassword); userModel.setResetPasswordToken(null); userStore.saveOrUpdate(userModel); userMailService.sendGeneratedPasswordMail(userModel, newPassword); response = new ServiceResponse("Email with new generated password has been sent.", true); } else { response = new ServiceResponse("Can't find User by token: " + token, false); } } else { response = new ServiceResponse("Token has expired.", false); } } catch (Exception e) { response = new ServiceResponse("Token is not valid.", false); } return response; }
From source file:com.vmware.bdd.cli.http.DefaultTrustManager.java
private boolean checkExpired(Date notBefore, Date notAfter) { Date now = new Date(); if (now.before(notBefore) || now.after(notAfter)) { return true; }/*from w ww . j a v a 2s . com*/ return false; }