List of usage examples for java.util Date before
public boolean before(Date when)
From source file:edu.cornell.mannlib.vitro.webapp.controller.accounts.user.UserAccountsPasswordBasePage.java
private void validateUserAccountInfo() { userAccount = userAccountsDao.getUserAccountByEmail(userEmail); if (userAccount == null) { log.warn("Password request for '" + userEmail + "' is bogus: no such user"); bogusMessage = i18n.text("account_no_longer_exists"); return;/*from w w w .ja v a 2s . co m*/ } if (userAccount.getPasswordLinkExpires() == 0L) { log.info("Password request for '" + userEmail + "' is bogus: password change is not pending."); bogusMessage = passwordChangeNotPendingMessage(); return; } if (userAccount.isExternalAuthOnly()) { log.info("Password request for '" + userEmail + "' is bogus: account is external auth only."); bogusMessage = passwordChangeNotPendingMessage(); return; } Date expirationDate = new Date(userAccount.getPasswordLinkExpires()); if (expirationDate.before(new Date())) { log.info("Password request for '" + userEmail + "' is bogus: expiration date has passed."); bogusMessage = passwordChangeNotPendingMessage(); return; } String expectedKey = userAccount.getPasswordLinkExpiresHash(); if (!key.equals(expectedKey)) { log.warn("Password request for '" + userEmail + "' is bogus: key (" + key + ") doesn't match expected key (" + expectedKey + ")"); bogusMessage = passwordChangeNotPendingMessage(); return; } UserAccount currentUser = LoginStatusBean.getCurrentUser(vreq); if (currentUser != null) { loggedIn = true; String currentUserEmail = currentUser.getEmailAddress(); if (!userEmail.equals(currentUserEmail)) { log.info("Password request for '" + userEmail + "' when already logged in as '" + currentUserEmail + "'"); bogusMessage = alreadyLoggedInMessage(currentUserEmail); return; } } }
From source file:com.intuit.tank.persistence.databases.MetricsCalculator.java
private boolean skipDate(Date date, Date start, Date end) { boolean ret = false; if (start != null && date.before(start)) { ret = true;/*from w ww. j a v a 2 s. co m*/ } else if (end != null && date.after(end)) { ret = true; } return ret; }
From source file:net.sf.statcvs.output.xml.chart.LocChart.java
private void updateSymbolicNamesMap(CvsRevision rev) { String[] symnames = rev.getSymbolicNames(); if (symnames.length != 0) { for (int i = 0; i < symnames.length; i++) { Date lastDate = (Date) tagMap.get(symnames[i]); if ((lastDate == null) || (lastDate.before(rev.getDate()))) { tagMap.put(symnames[i], rev.getDate()); }//ww w. ja va2s.c o m } } }
From source file:it.reply.orchestrator.service.security.UserInfoIntrospectingTokenService.java
private void preValidate(SignedJWT jwtToken) throws ParseException { Date expirationTime = jwtToken.getJWTClaimsSet().getExpirationTime(); if (expirationTime != null) { if (expirationTime.before(new Date())) { throw new InvalidTokenException("access token is expired"); }/* ww w.j a v a 2 s.c o m*/ } String issuer = getIssuer(jwtToken); ServerConfiguration serverConfiguration = getServerConfiguration(issuer); JWTSigningAndValidationService validationService = validationServices .getValidator(serverConfiguration.getJwksUri()); if (validationService != null) { if (!validationService.validateSignature((SignedJWT) jwtToken)) { throw new InvalidTokenException("access token has an invalid signature"); } } else { LOG.warn("Couldn't retrive validator for issuer {}, validation of access token skipped", issuer); } }
From source file:com.arantius.tivocommander.Upcoming.java
protected String formatTime(JsonNode item) throws DateInPast { String timeIn = item.path("startTime").asText(); if (timeIn == null) { return null; }/*w w w. j av a 2 s .c om*/ Date playTime = Utils.parseDateTimeStr(timeIn); if (playTime.before(new Date())) { throw new DateInPast(); } SimpleDateFormat dateFormatter = new SimpleDateFormat("EEE M/d hh:mm a", Locale.US); dateFormatter.setTimeZone(TimeZone.getDefault()); return dateFormatter.format(playTime); }
From source file:com.netflix.genie.core.jpa.entities.BaseEntity.java
/** * Set the created timestamp. This is a No-Op. Set once by system. * * @param created The created timestamp/*w ww. ja v a 2 s .c o m*/ */ public void setCreated(final Date created) { log.debug("Tried to set created to {} for entity {}. Will not be persisted.", created, this.id); if (created.before(this.created)) { this.created = new Date(created.getTime()); } }
From source file:com.runwaysdk.business.email.EmailKey.java
/** * Checks if this EmailKey is valid by comparing the value * of the issue date with the current date. If the difference * between those two dates is greater than the number of days * specified by the value of keyExpire in email.properties then * the EmailKey is invalid. If this EmailKey is invalid, it is up * to the developer to delete it and re-issue a new one. * //from w w w . j ava2 s . co m * @return */ public boolean isDateValid() { Date issued = getIssuedOnDate(); int expireDays = EmailProperties.getKeyExpire(); Date expireDate = DateUtils.addDays(issued, expireDays); Date now = new Date(); return now.before(expireDate); }
From source file:com.eryansky.common.utils.DateUtil.java
public static boolean isDateBefore(String date2) { try {/* w ww. jav a 2s . c om*/ Date date1 = new Date(); DateFormat df = DateFormat.getDateTimeInstance(); return date1.before(df.parse(date2)); } catch (ParseException e) { System.out.print("[SYS] " + e.getMessage()); return false; } }
From source file:it.jnrpe.plugin.CheckTime.java
/** * Analizes the data and produces the metrics. * //from w ww . j a v a2s . c o m * @param metrics * produced metrics * @param elapsed * elapsed time * @param now * date as of now * @param date */ private void analyze(final List<Metric> metrics, final long elapsed, final Date now, final Date date) { long diff = 0; boolean behind = false; if (now.before(date)) { behind = true; diff = date.getTime() - now.getTime(); } else if (now.after(date)) { diff = now.getTime() - date.getTime(); } Elapsed elapsedTime = new Elapsed(diff, TimeUnit.MILLISECOND); String msg = getMessage(elapsedTime); if (diff > TimeUnit.SECOND.convert(1)) { if (behind) { msg += "behind"; } else { msg += "ahead"; } } metrics.add(new Metric("offset", msg, new BigDecimal(TimeUnit.MILLISECOND.convert(diff, TimeUnit.SECOND)), null, null)); metrics.add(new Metric("time", "", new BigDecimal(TimeUnit.MILLISECOND.convert(elapsed, TimeUnit.SECOND)), null, null)); }
From source file:com.norconex.commons.lang.time.YearMonthDayInterval.java
/** * Whether the date falls between this interval * (inclusive endpoints)./* w ww . ja va2s . c o m*/ * @param date a date * @return <code>true</code> if the date is included in this interval */ public boolean contains(Date date) { Date startDate = start.toDate(); Date endDate = end.toDate(); if (startDate.after(date)) { return false; } if (endDate.before(date)) { return false; } return true; }