List of usage examples for java.util Date after
public boolean after(Date when)
From source file:de.iteratec.iteraplan.presentation.dialog.GraphicalReporting.Line.JFreeChartLineGraphicCreator.java
public void setToDate(Date toDate) { Date currentDate = new Date(); if (toDate.after(currentDate)) { this.toDate = currentDate; } else {// w ww. j a v a 2 s . co m this.toDate = toDate; } }
From source file:org.openmrs.module.laboratory.web.ajax.AjaxController.java
@RequestMapping(value = "/module/laboratory/ajax/validateRescheduleDate.htm", method = RequestMethod.GET) public void validateRescheduleDate(@RequestParam("rescheduleDate") String rescheduleDateStr, HttpServletResponse response) throws IOException, ParseException { response.setContentType("text/html;charset=UTF-8"); PrintWriter writer = response.getWriter(); Date rescheduleDate = LaboratoryUtil.parseDate(rescheduleDateStr + " 00:00:00"); Date now = new Date(); String currentDateStr = LaboratoryUtil.formatDate(now) + " 00:00:00"; Date currentDate = LaboratoryUtil.parseDate(currentDateStr); if (rescheduleDate.after(currentDate)) writer.print("success"); else/*from w ww . j av a2 s .com*/ writer.print("fail"); }
From source file:com.esofthead.mycollab.module.project.domain.SimpleTaskList.java
public Date getStartDate() { Date result = null; for (SimpleTask task : subTasks) { if (task.getStartdate() != null) { if (result == null) { result = task.getStartdate(); } else { if (result.after(task.getStartdate())) { result = task.getStartdate(); }/*from w w w. ja v a2s .c om*/ } } } return result; }
From source file:se.inera.axel.shs.broker.agreement.mongo.MongoAgreementService.java
private void isValidNow(ShsAgreement agreement) { General general = agreement.getGeneral(); if (general == null) return;//from w ww .j av a 2s . co m Valid valid = general.getValid(); if (valid == null) return; ValidFrom validFrom = valid.getValidFrom(); Date fromDate = validFrom == null ? null : validFrom.getDate(); ValidTo validTo = agreement.getGeneral().getValid().getValidTo(); Date toDate = validTo == null ? null : validTo.getDate(); Date today = new Date(); if ((fromDate != null && today.before(fromDate)) || (toDate != null && today.after(toDate))) { throw new IllegalAgreementException("the current time is outside validity period of agreement"); } }
From source file:com.feilong.core.date.DateUtil.java
/** * <code>date</code> ? <code>beginTimeDate</code> <code>endTimeDate</code>. * /*w ww. j a va 2 s .c om*/ * <pre class="code"> * DateUtil.isInTime("2012-10-16 23:00:02", "2012-10-10 22:59:00", "2012-10-18 22:59:00") = true * </pre> * * @param date * * @param beginTimeDate * the begin time date * @param endTimeDate * the end time date * @return <code>date</code> <code>beginTimeDate</code>?, <code>date</code> <code>endTimeDate</code>?,true<br> * @throws NullPointerException * <code>date</code> null, <code>beginTimeDate</code> null <code>endTimeDate</code> null * @see Date#after(Date) * @see Date#before(Date) */ public static boolean isInTime(Date date, Date beginTimeDate, Date endTimeDate) { Validate.notNull(date, "date can't be null!"); Validate.notNull(beginTimeDate, "beginTimeDate can't be null!"); Validate.notNull(endTimeDate, "endTimeDate can't be null!"); return date.after(beginTimeDate) && date.before(endTimeDate); }
From source file:strat.mining.multipool.stats.builder.WaffleStatsBuilder.java
private AddressStats updateAddressStats(Address address, Date refreshDate) throws Exception { LOGGER.debug("Update addressStats for Waffle address {}.", address.getAddress()); long start = System.currentTimeMillis(); strat.mining.multipool.stats.jersey.model.waffle.AddressStats rawAddressStats = waffleRestClient .getAddressStats(address.getAddress()); AddressStats result = null;// www. java 2 s.co m if (rawAddressStats != null && StringUtils.isEmpty(rawAddressStats.getError())) { result = new AddressStats(); result.setAddressId(address.getId()); result.setBalance( rawAddressStats.getBalances() == null || rawAddressStats.getBalances().getConfirmed() == null ? 0 : rawAddressStats.getBalances().getConfirmed().floatValue()); result.setUnexchanged( rawAddressStats.getBalances() == null || rawAddressStats.getBalances().getUnconverted() == null ? 0 : rawAddressStats.getBalances().getUnconverted().floatValue()); result.setPaidout( rawAddressStats.getBalances() == null || rawAddressStats.getBalances().getSent() == null ? 0 : rawAddressStats.getBalances().getSent().floatValue()); result.setHashRate( rawAddressStats.getHash_rate() == null ? 0 : rawAddressStats.getHash_rate().floatValue()); result.setRefreshTime(refreshDate); List<WorkerStats> workersStats = new ArrayList<>(); if (CollectionUtils.isNotEmpty(rawAddressStats.getWorker_hashrates())) { Calendar calendar = GregorianCalendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, -7); for (Worker_hashrates workerHasrate : rawAddressStats.getWorker_hashrates()) { // Keep the worker stats only if it has been seen in the 7 // previous days Date lastSeen = new Date(workerHasrate.getLast_seen().longValue() * 1000); if (lastSeen.after(calendar.getTime())) { WorkerStats worker = new WorkerStats(); if (workerHasrate.getUsername() != null) { worker.setUsername(workerHasrate.getUsername()); worker.setHashrate(workerHasrate.getHashrate() == null ? 0 : workerHasrate.getHashrate().floatValue()); worker.setStaleRate(workerHasrate.getStalerate() == null ? 0 : workerHasrate.getStalerate().floatValue()); workersStats.add(worker); } } } } result.setWorkerStats(workersStats); addressStatsDao.insertAddressStats(result); Transaction lastTransaction = transactionDao.getLastTransaction(address.getId()); SimpleDateFormat dateFormat = new SimpleDateFormat(PAYEMENT_DATE_PATTERN); if (CollectionUtils.isNotEmpty(rawAddressStats.getRecent_payments())) { for (Recent_payments payement : rawAddressStats.getRecent_payments()) { Date payementDate = dateFormat.parse(payement.getTime()); if (lastTransaction == null || lastTransaction.getDate().before(payementDate)) { Transaction transaction = new Transaction(); transaction.setAddressId(address.getId()); transaction .setAmount(payement.getAmount() == null ? 0 : Float.valueOf(payement.getAmount())); transaction.setDate(payementDate); transaction.setTransactionId(payement.getTxn()); transactionDao.insertTransaction(transaction); } else { // When all last transactions are inserted, just break break; } } } } else { throw new Exception( rawAddressStats == null ? "Unable to retrieve Waffle raw stats for address " + address : rawAddressStats.getError()); } PERF_LOGGER.debug("Waffle address {} updated in {} ms.", address.getAddress(), System.currentTimeMillis() - start); return result; }
From source file:be.e_contract.eid.applet.service.impl.handler.IdentityDataMessageHandler.java
@Override public Object handleMessage(IdentityDataMessage message, Map<String, String> httpHeaders, HttpServletRequest request, HttpSession session) throws ServletException { LOG.debug("handle identity"); X509Certificate rrnCertificate = getCertificate(message.rrnCertFile); X509Certificate rootCertificate = getCertificate(message.rootCertFile); List<X509Certificate> rrnCertificateChain = new LinkedList<X509Certificate>(); rrnCertificateChain.add(rrnCertificate); rrnCertificateChain.add(rootCertificate); IdentificationEvent identificationEvent = new IdentificationEvent(rrnCertificateChain); BeIDContextQualifier contextQualifier = new BeIDContextQualifier(request); try {//from w w w.j a v a 2 s . c om this.identificationEvent.select(contextQualifier).fire(identificationEvent); } catch (ExpiredCertificateSecurityException e) { return new FinishedMessage(ErrorCode.CERTIFICATE_EXPIRED); } catch (RevokedCertificateSecurityException e) { return new FinishedMessage(ErrorCode.CERTIFICATE_REVOKED); } catch (TrustCertificateSecurityException e) { return new FinishedMessage(ErrorCode.CERTIFICATE_NOT_TRUSTED); } catch (CertificateSecurityException e) { return new FinishedMessage(ErrorCode.CERTIFICATE); } if (false == identificationEvent.isValid()) { SecurityAuditEvent securityAuditEvent = new SecurityAuditEvent(Incident.TRUST, rrnCertificate); this.securityAuditEvent.select(contextQualifier).fire(securityAuditEvent); throw new SecurityException("invalid national registry certificate chain"); } verifySignature(contextQualifier, rrnCertificate.getSigAlgName(), message.identitySignatureFile, rrnCertificate, request, message.idFile); Identity identity = TlvParser.parse(message.idFile, Identity.class); if (null != message.photoFile) { LOG.debug("photo file size: " + message.photoFile.length); /* * Photo integrity check. */ byte[] expectedPhotoDigest = identity.photoDigest; byte[] actualPhotoDigest = digestPhoto(getDigestAlgo(expectedPhotoDigest.length), message.photoFile); if (false == Arrays.equals(expectedPhotoDigest, actualPhotoDigest)) { SecurityAuditEvent securityAuditEvent = new SecurityAuditEvent(Incident.DATA_INTEGRITY, message.photoFile); this.securityAuditEvent.select(contextQualifier).fire(securityAuditEvent); throw new ServletException("photo digest incorrect"); } } Address address; if (null != message.addressFile) { byte[] addressFile = trimRight(message.addressFile); verifySignature(contextQualifier, rrnCertificate.getSigAlgName(), message.addressSignatureFile, rrnCertificate, request, addressFile, message.identitySignatureFile); address = TlvParser.parse(message.addressFile, Address.class); } else { address = null; } /* * Check the validity of the identity data as good as possible. */ GregorianCalendar cardValidityDateEndGregorianCalendar = identity.getCardValidityDateEnd(); if (null != cardValidityDateEndGregorianCalendar) { Date now = new Date(); Date cardValidityDateEndDate = cardValidityDateEndGregorianCalendar.getTime(); if (now.after(cardValidityDateEndDate)) { SecurityAuditEvent securityAuditEvent = new SecurityAuditEvent(Incident.DATA_INTEGRITY, message.idFile); this.securityAuditEvent.select(contextQualifier).fire(securityAuditEvent); throw new SecurityException("eID card has expired"); } } this.identityEvent.select(contextQualifier).fire(new IdentityEvent(identity, address, message.photoFile)); return new FinishedMessage(); }
From source file:org.dspace.orm.entity.ResourcePolicy.java
@Transient public boolean isDateValid() { Date sd = getStartDate();/* ww w . j a v a 2s . co m*/ Date ed = getEndDate(); // if no dates set, return true (most common case) if ((sd == null) && (ed == null)) { return true; } // one is set, now need to do some date math Date now = new Date(); // check start date first if (sd != null && now.before(sd)) { // start date is set, return false if we're before it return false; } // now expiration date if (ed != null && now.after(ed)) { // end date is set, return false if we're after it return false; } // if we made it this far, start < now < end return true; // date must be okay }
From source file:cn.loveapple.client.android.database.impl.TemperatureDaoImpl.java
/** * ?????????/*from w ww . jav a 2s . c om*/ * @param startDate * @return */ private SortedSet<String> createDateKey(String startDate) { SortedSet<String> result = new TreeSet<String>(); Date now = new Date(); Date start = DateUtil.paseDate(startDate, DateUtil.DATE_PTTERN_YYYYMMDD); Calendar date = Calendar.getInstance(); date.setTime(start); for (int i = 0; now.after(date.getTime()); i++, date.set(Calendar.DAY_OF_MONTH, date.get(Calendar.DAY_OF_MONTH) + 1)) { result.add(DateUtil.toDateString(date.getTime())); } return result; }
From source file:com.discovery.darchrow.date.DateUtil.java
/** * ??./*from w ww . j a v a2s. co m*/ * * <pre> * :2012-10-16 23:00:02 * * isInTime(date, "2012-10-10 22:59:00", "2012-10-18 22:59:00") * * return true * </pre> * * @param date * ? * @param beginTimeDate * the begin time date * @param endTimeDate * the end time date * @return {@code date after beginTimeDate&&?before endTimeDate,true} * @see Date#after(Date) * @see Date#before(Date) */ public static boolean isInTime(Date date, Date beginTimeDate, Date endTimeDate) { return date.after(beginTimeDate) && date.before(endTimeDate); }