List of usage examples for java.util Date after
public boolean after(Date when)
From source file:org.commonjava.indy.ftest.core.content.RemoteRepoTimeoutDisablesStoreAndRetreiveTimeoutScheduleTest.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.setTimeoutSeconds(1);//from ww w.j ava2 s. com 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)); } Thread.sleep(1000); RemoteRepository result = client.stores().load(remote, repo1, RemoteRepository.class); assertThat(result.isDisabled(), equalTo(true)); Date timeout = client.schedules().getStoreDisableTimeout(remote, repo1); assertThat(timeout.after(new Date()), equalTo(true)); }
From source file:org.jasig.ssp.util.importer.job.tasklet.PartialUploadGuard.java
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { Date lastAllowedModificationTime = getLastAllowedModifiedDate(); if (resources == null || resources.length == 0) { logger.error("Job not started. No resources found"); stopJob();/*w w w . j a v a 2s . c o m*/ return RepeatStatus.FINISHED; } for (Resource resource : resources) { Date modified = new Date(resource.lastModified()); if (modified.after(lastAllowedModificationTime)) { logger.info(FILE_SOAK_TIME + resource.getFilename()); stopJob(); return RepeatStatus.FINISHED; } } return RepeatStatus.FINISHED; }
From source file:com.jdom.get.stuff.done.domain.DueWithinDatesFilterOption.java
public boolean accept(Task task) { Date date = task.getDueDate(); return (date.equals(earliest) || date.equals(latest) || (date.after(earliest) && date.before(latest))); }
From source file:com.salesmanager.core.util.ProductUtil.java
public static BigDecimal determinePriceWithAttributes(Product product, Collection attributes, Locale locale, String currency) {//from w ww .j a v a 2 s . co m int decimalPlace = 2; Map currenciesmap = RefCache.getCurrenciesListWithCodes(); Currency c = (Currency) currenciesmap.get(currency); // prices BigDecimal bdprodprice = product.getProductPrice(); BigDecimal bddiscountprice = null; // discount price Special special = product.getSpecial(); Date dt = new Date(); java.util.Date spdate = null; java.util.Date spenddate = null; if (special != null) { spdate = special.getSpecialDateAvailable(); spenddate = special.getExpiresDate(); if (spdate.before(new Date(dt.getTime())) && spenddate.after(new Date(dt.getTime()))) { bddiscountprice = special.getSpecialNewProductPrice(); } } // all other prices Set prices = product.getPrices(); if (prices != null) { Iterator pit = prices.iterator(); while (pit.hasNext()) { ProductPrice pprice = (ProductPrice) pit.next(); pprice.setLocale(locale); if (pprice.isDefaultPrice()) {// overwrites default price bddiscountprice = null; spdate = null; spenddate = null; bdprodprice = pprice.getProductPriceAmount(); ProductPriceSpecial ppspecial = pprice.getSpecial(); if (ppspecial != null) { if (ppspecial.getProductPriceSpecialStartDate() != null && ppspecial.getProductPriceSpecialEndDate() != null && ppspecial.getProductPriceSpecialStartDate().before(new Date(dt.getTime())) && ppspecial.getProductPriceSpecialEndDate().after(new Date(dt.getTime()))) { bddiscountprice = ppspecial.getProductPriceSpecialAmount(); } else if (ppspecial.getProductPriceSpecialDurationDays() > -1) { bddiscountprice = ppspecial.getProductPriceSpecialAmount(); } } break; } } } double fprodprice = 0; ; if (bdprodprice != null) { fprodprice = bdprodprice.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP).doubleValue(); } // determine any properties prices BigDecimal attributesPrice = null; if (attributes != null) { Iterator i = attributes.iterator(); while (i.hasNext()) { ProductAttribute attr = (ProductAttribute) i.next(); if (!attr.isAttributeDisplayOnly() && attr.getOptionValuePrice().longValue() > 0) { if (attributesPrice == null) { attributesPrice = new BigDecimal(0); } attributesPrice = attributesPrice.add(attr.getOptionValuePrice()); } } } if (bddiscountprice != null) { if (attributesPrice != null) { bddiscountprice = bddiscountprice.add(attributesPrice); } return bddiscountprice; } else { if (attributesPrice != null) { bdprodprice = bdprodprice.add(attributesPrice); } return bdprodprice; } }
From source file:com.twitter.hraven.hadoopJobMonitor.jmx.WhiteList.java
public boolean isWhiteListed(String appId, Date now) { Date expDate = expirationMap.get(appId); boolean whiteListed = expDate != null && expDate.after(now); if (expDate != null && !whiteListed) expirationMap.remove(appId);/* w w w. j a va2s .co m*/ return whiteListed; }
From source file:lolthx.autohome.buy.AutohomePriceListFetch.java
private boolean between(Date beginDate, Date endDate, Date src) { return beginDate.before(src) && endDate.after(src); }
From source file:de.hybris.platform.acceleratorservices.order.strategies.impl.ReminderUncollectedConsignmentStrategy.java
@Override public boolean processConsignment(final ConsignmentModel consignmentModel) { if (consignmentModel != null) { final Date timeLimit = DateUtils.addHours(new Date(), 0 - getTimeThreshold().intValue()); if (timeLimit.after(consignmentModel.getShippingDate())) { if (getBusinessProcessService() .getProcess("consignmentCollectionReminderProcess-" + consignmentModel.getCode()) == null) { if (LOG.isDebugEnabled()) { LOG.debug("Process consignmentCollectionReminderProcess-" + consignmentModel.getCode() + " created."); }/* w w w. ja v a 2 s . c om*/ final ConsignmentProcessModel consignmentProcessModel = getBusinessProcessService() .createProcess("consignmentCollectionReminderProcess-" + consignmentModel.getCode(), "consignmentCollectionReminderProcess"); if (consignmentProcessModel != null) { consignmentProcessModel.setConsignment(consignmentModel); getModelService().save(consignmentProcessModel); getBusinessProcessService().startProcess(consignmentProcessModel); return true; } } } } return false; }
From source file:com.hobba.hobaserver.services.security.TokenUtil.java
public boolean authenticateToken(String token, String kid) { byte[] decodedToken = Base64.decodeBase64(token.getBytes()); String decodedTokenString = new String(decodedToken); String[] fields = decodedTokenString.split(":"); HobaKeysFacadeREST hkfrest = new HobaKeysFacadeREST(); HobaKeys hk = hkfrest.findHKIDbyKID(fields[0]); int userID = hk.getIdDevices().getIduser().getIdUser(); HobaUser hu = hk.getIdDevices().getIduser(); HobaTokenFacadeREST htfrest = new HobaTokenFacadeREST(); HobaToken ht = htfrest.findTokenbyToken(fields[1]); Date date = new Date(); if (ht.getExpiration() != null) { if (date.after(ht.getExpiration())) { return false; }/* w w w. j av a 2 s . c om*/ } else { if (!ht.getIsValid()) { return false; } ht.setIsValid(Boolean.FALSE); } HobaUser hu1 = ht.getIdUser(); if (hu.getIdUser() != userID) { return false; } hk = hkfrest.findHKIDbyKID(kid); HobaDevices hd = hk.getIdDevices(); hd.setIduser(hu); HobaDevicesFacadeREST hdfrest = new HobaDevicesFacadeREST(); htfrest.create(ht); hdfrest.create(hd); return true; }
From source file:com.alibaba.otter.shared.common.utils.cache.RefreshMemoryMirror.java
/** * ?// ww w . j a va 2s. c o m * * @param refreshObject * @return */ private boolean isExpired(RefreshObject refreshObject) { if (refreshObject == null) { return false; } Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(refreshObject.getTimestamp()); // calendar.add(Calendar.SECOND, period.intValue()); calendar.add(Calendar.MILLISECOND, period.intValue()); Date now = new Date(); return now.after(calendar.getTime()); }
From source file:de.hybris.platform.acceleratorservices.order.strategies.impl.CustomerServiceUncollectedConsignmentStrategy.java
@Override public boolean processConsignment(final ConsignmentModel consignmentModel) { if (consignmentModel != null) { final Date timeLimit = DateUtils.addHours(new Date(), 0 - getTimeThreshold().intValue()); if (timeLimit.after(consignmentModel.getShippingDate())) { if (getBusinessProcessService().getProcess( "moveConsignmentToCustomerServicesProcess-" + consignmentModel.getCode()) == null) { if (LOG.isDebugEnabled()) { LOG.debug("Process moveConsignmentToCustomerServicesProcess-" + consignmentModel.getCode() + " created."); }/*from w ww. j ava 2 s. co m*/ final ConsignmentProcessModel consignmentProcessModel = getBusinessProcessService() .createProcess("moveConsignmentToCustomerServicesProcess-" + consignmentModel.getCode(), "moveConsignmentToCustomerServicesProcess"); if (consignmentProcessModel != null) { consignmentProcessModel.setConsignment(consignmentModel); getModelService().save(consignmentProcessModel); getBusinessProcessService().startProcess(consignmentProcessModel); return true; } } } } return false; }