List of usage examples for java.util Date before
public boolean before(Date when)
From source file:be.e_contract.mycarenet.common.SessionKey.java
/** * Checks whether this MyCareNet session key still operates within its * validity period.//from w ww. j ava 2 s . c o m * * @return */ public boolean isValid() { if (null == this.notBefore) { LOG.debug("no notBefore"); return false; } if (null == this.notAfter) { LOG.debug("no notAfter"); return false; } Date now = new Date(); if (now.before(this.notBefore)) { LOG.debug("session key not yet active"); LOG.debug("now: " + now); LOG.debug("notBefore: " + this.notBefore); return false; } if (now.after(this.notAfter)) { LOG.debug("session key expired"); return false; } return true; }
From source file:arena.httpclient.redundant.HostPool.java
/** * Iterates the list of hosts, until it finds a valid one *//*ww w .j a va 2 s . c o m*/ public HostConfig getHost() { HostConfig found = null; synchronized (this) { for (int n = 0; (n < this.hostConfigs.length) && (found == null); n++) { HostConfig test = (HostConfig) this.hostConfigs[n]; Date availableFrom = (Date) this.availableDates.get(test); if (availableFrom != null) { // If the date has passed, mark it as valid and exit if (availableFrom.before(new Date())) { this.availableDates.remove(test); found = test; log.debug("Flagging host as recovered: " + test.getHostname()); } } else { found = test; } } } return found; }
From source file:net.audumla.scheduler.quartz.AstronomicTriggerImpl.java
@Override public Date computeFirstFireTime(Calendar cal) { // seed the start event calendar = cal;/*from w w w. java 2s.co m*/ Date fireTime = org.apache.commons.lang3.time.DateUtils .addSeconds(schedule.startTime.getCalculatedEventTime(), (int) schedule.startOffset); while (fireTime.before(getStartTime())) { schedule.startTime = schedule.startTime.getNextEvent(); fireTime = org.apache.commons.lang3.time.DateUtils .addSeconds(schedule.startTime.getCalculatedEventTime(), (int) schedule.startOffset); } setNextFireTime(fireTime); ++eventCount; // set the event count as the first trigger will not increment this return getNextFireTime(); }
From source file:net.audumla.climate.bom.BOMHistoricalClimateObserver.java
public boolean supportsDate(Date date) { return !invalidMonths.contains(Time.getMonthAndYear(date)) && date.before(Time.getToday()); }
From source file:co.cask.hydrator.plugin.batch.source.XMLReaderBatchSource.java
/** * Method to set file tracking information in to configuration. *//*from w w w . jav a 2 s. c o m*/ private void setFileTrackingInfo(BatchSourceContext context, Configuration conf) { //For reprocessing not required, set processed file name to configuration. processedFileTrackingTable = context.getDataset(config.tableName); if (processedFileTrackingTable != null && !config.isReprocessingRequired()) { List<String> processedFiles = new ArrayList<String>(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -Integer.valueOf(config.tableExpiryPeriod)); Date expiryDate = cal.getTime(); try (CloseableIterator<KeyValue<byte[], byte[]>> iterator = processedFileTrackingTable.scan(null, null)) { while (iterator.hasNext()) { KeyValue<byte[], byte[]> keyValue = iterator.next(); //Delete record before expiry time period Long time = Bytes.toLong(keyValue.getValue()); Date processedDate = new Date(time); if (processedDate.before(expiryDate)) { processedFileTrackingTable.delete(keyValue.getKey()); } else { processedFiles.add(Bytes.toString(keyValue.getKey())); } } } //File name use by BatchXMLFileFilter to filter already processed files. conf.set(XMLInputFormat.XML_INPUTFORMAT_PROCESSED_FILES, GSON.toJson(processedFiles, ARRAYLIST_PREPROCESSED_FILES)); } }
From source file:com.salesmanager.checkout.files.FilesAction.java
public String accessUrl() { try {//www . j av a 2 s . com // parse file download request String fileId = getServletRequest().getParameter("fileId"); String lang = getServletRequest().getParameter("lang"); if (StringUtils.isBlank(fileId)) { List msg = new ArrayList(); msg.add(getText("error.downloadurl.invalid")); super.setActionErrors(msg); return "GENERICERROR"; } Map fileInfo = FileUtil.getUrlTokens(fileId); String order = (String) fileInfo.get("ID"); String date = (String) fileInfo.get("DATE"); orderId = order; // Compare the date Date today = new Date(); DateFormat d = new SimpleDateFormat("yyyy-MM-dd"); Date dt = null; dt = d.parse(date); if (dt.before(new Date(today.getTime()))) { // expired CoreException excpt = new CoreException(ErrorConstants.DELAY_EXPIRED); throw excpt; } } catch (Exception e) { if (e instanceof CoreException) { String message = getText("error.downloadurl.expired"); this.setFileMessage(message); return "DELAYEXPIRED"; } else { log.error(e); super.setTechnicalMessage(); return "GENERICERROR"; } } return SUCCESS; }
From source file:net.refractions.udig.catalog.wmsc.server.TileImageReadWriter.java
/** * Check the tiles last modified time + max cache time v.s. the current time. If its before the * current time the tile is considered out-dated and should be pulled from the server. * //from w w w . ja v a 2s. co m * @param tile The Tile Object * @param tileFile the tile image File * @return true if the tile is considered out-dated, false otherwise */ public boolean isTileStale(Tile tile, String filetype) { String filename = getTileFileName(tile, filetype); File tileFile = new File(filename); String cacheFilename = getCacheFilename(tile); File cacheFile = new File(cacheFilename); if (cacheFile.exists()) { try { String persistedCacheAge = FileUtils.readFileToString(cacheFile); if (persistedCacheAge != null && !"".equals(persistedCacheAge)) { //$NON-NLS-1$ Long cacheTimeLong = Long.parseLong(persistedCacheAge); Date cacheTime = new Date(tileFile.lastModified() + (cacheTimeLong * 1000)); if (cacheTime.before(new Date(System.currentTimeMillis()))) { return true; } } else { /* * if we get to here the cache file might have been written without a max cache * age, or corrupted; lets assume the tile is stale */ return true; } } catch (IOException e) { e.printStackTrace(); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } } return false; }
From source file:net.solarnetwork.node.setup.web.NodeCertificatesController.java
/** * View the main certs page./*from ww w. ja v a 2 s . c om*/ * * @param model * the view model * @return */ @RequestMapping public String home(Model model) { X509Certificate nodeCert = pkiService.getNodeCertificate(); final Date now = new Date(); final boolean expired = (nodeCert != null && now.after(nodeCert.getNotAfter())); final boolean valid = (nodeCert != null && (!nodeCert.getIssuerDN().equals(nodeCert.getSubjectDN()) && !now.before(nodeCert.getNotBefore()) && !expired)); model.addAttribute("nodeCert", nodeCert); model.addAttribute("nodeCertExpired", expired); model.addAttribute("nodeCertValid", valid); return "certs/home"; }
From source file:fr.cph.stock.controller.portfolio.PortfolioController.java
@RequestMapping(value = "/performance", method = RequestMethod.GET) public ModelAndView performance( @RequestParam(value = FROM, required = false) @DateTimeFormat(pattern = DATE_FORMAT) final Date fromDate, @RequestParam(value = TO, required = false) @DateTimeFormat(pattern = DATE_FORMAT) final Date toDate, @Valid @ModelAttribute final User user, @CookieValue(LANGUAGE) final String lang) throws ServletException, ParseException { final ModelAndView model = new ModelAndView("performance"); try {/*w w w . j a v a2s. c o m*/ final Portfolio portfolio = userService.getUserPortfolio(user.getId(), fromDate, toDate) .orElseThrow(() -> new NotFoundException(user.getId())); if (portfolio.getShareValues().size() != 0) { Date from = portfolio.getShareValues().get(portfolio.getShareValues().size() - 1).getDate(); // Reset time to 17:00PM to get also the cac40 into the day selected (or it would not select it from = Util.resetHourMinSecMill(from); // Put 17:00PM to the first sharevalue, to make it nice in graphic portfolio.getShareValues().get(portfolio.getShareValues().size() - 1).setDate(from); // FIXME that should be done already into get user portfolio. To verify. final List<Index> indexesCAC40 = indexService.getIndexes(Constants.CAC_40, from, toDate); final List<Index> indexesSP500 = indexService.getIndexes(Constants.SP_500, from, toDate); portfolio.addIndexes(indexesCAC40); portfolio.addIndexes(indexesSP500); portfolio.compute(); Date fro = from; if (indexesCAC40.size() > 0) { final Date date = indexesCAC40.get(0).getDate(); if (date.before(fro)) { fro = date; } } if (indexesSP500.size() > 0) { final Date date2 = indexesSP500.get(0).getDate(); if (date2.before(fro)) { fro = date2; } } Date t = portfolio.getShareValues().get(0).getDate(); if (indexesCAC40.size() > 1) { final Date date3 = indexesCAC40.get(indexesCAC40.size() - 1).getDate(); if (date3.after(t)) { t = date3; } } if (indexesSP500.size() > 1) { final Date date = indexesSP500.get(indexesSP500.size() - 1).getDate(); if (date.after(t)) { t = date; } } model.addObject(FROM_UNDERSCORE, fro); model.addObject(TO_UNDERSCORE, t); } model.addObject(PORTFOLIO, portfolio); } catch (final YahooException e) { log.error("Error: {}", e.getMessage(), e); } model.addObject(LANGUAGE, LanguageFactory.INSTANCE.getLanguage(lang)); model.addObject(APP_TITLE, appProperties.getName() + " • Performance"); return model; }