List of usage examples for java.util Date before
public boolean before(Date when)
From source file:com.ibm.bluemix.smartveggie.controller.VendorController.java
@RequestMapping(value = "/leaseSubOutlet.html", method = RequestMethod.GET) public String leaseSubOutlet(HttpServletRequest request, ModelMap model) { List<SmartCityDTO> smartCityLists = adminService.retreiveSmartCities(); List<OutletDTO> outletLists = outletService.getOutlets(); List<SubOutletDTO> suboutletLists = outletService.getSubOutlets(); HttpSession session = request.getSession(); UserDTO userDTO = (UserDTO) session.getAttribute("loginUserForm"); userDTO = userService.getUser(userDTO.getUserName(), userDTO.getPassword()); model.put("smartCityLists", smartCityLists); model.put("outletLists", outletLists); model.put("suboutletLists", suboutletLists); model.put("suboutletvendorAllocation", suboutletvendorAllocation); model.put("userDTO", userDTO); List<SubOutletVendorAllocationDTO> subOutletVendorAllocationList = subOutletVendorAllocationService .retrieveAllocatedSubOutlet(); model.put("subOutletVendorAllocationList", subOutletVendorAllocationList); List<SubOutletVendorAllocationDTO> subOutletNotAvailableList = new ArrayList<SubOutletVendorAllocationDTO>(); //Get only those suboutlet whose lease end date is less than current date Date currentDate = Calendar.getInstance().getTime(); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); if (subOutletVendorAllocationList != null) { for (SubOutletVendorAllocationDTO allocation : subOutletVendorAllocationList) { String allocationEndDate = allocation.getSuboutletAllocatedTo(); if (allocationEndDate != null && !allocationEndDate.equals("")) { Date allocEndDate = null; try { allocEndDate = dateFormat.parse(allocationEndDate); if (allocEndDate.before(currentDate)) { System.out.println("Allocation already ended...."); //subOutletAvailableList.add(allocation); } else { subOutletNotAvailableList.add(allocation); System.out.println("Already allocation to vendor...."); }/* w w w . j a v a2 s . c o m*/ } catch (Exception e) { e.printStackTrace(); } } } } List<SubOutletDTO> subOutletAvailableList = new ArrayList<SubOutletDTO>(); for (SubOutletDTO suboutlet : suboutletLists) { String smartCity = suboutlet.getSubOutletCityCode(); String smartOutlet = suboutlet.getOutletCode(); String smartSuboutlet = suboutlet.getSubOutletCode(); boolean notAvailable = false; for (SubOutletVendorAllocationDTO suboutletNotAvailable : subOutletNotAvailableList) { String smartCityNotAvailable = suboutletNotAvailable.getSmartCityCode(); String smartCityOutletNotAvailable = suboutletNotAvailable.getSmartOutletCode(); String smartCitySuboutletNotAvailable = suboutletNotAvailable.getSuboutletCode(); if (smartCity.equalsIgnoreCase(smartCityNotAvailable) && smartOutlet.equalsIgnoreCase(smartCityOutletNotAvailable) && smartSuboutlet.equalsIgnoreCase(smartCitySuboutletNotAvailable)) { //Do nothing as tis outlet is unavaialble notAvailable = true; break; } } if (!notAvailable) { subOutletAvailableList.add(suboutlet); } System.out.println("suboutlet available list..." + subOutletAvailableList); } model.put("subOutletAvailableList", subOutletAvailableList); List<SubOutletVendorAllocationDTO> vendorAllocationList = new ArrayList<SubOutletVendorAllocationDTO>(); model.put("subOutletVendorAllocationList", subOutletVendorAllocationList); for (SubOutletVendorAllocationDTO vendorAlloc : subOutletVendorAllocationList) { if (vendorAlloc.getVendorUsername() != null && vendorAlloc.getVendorUsername().equalsIgnoreCase(userDTO.getUserName())) { vendorAllocationList.add(vendorAlloc); } } model.put("vendorAllocationList", vendorAllocationList); return "admin/leaseSubOutlet"; }
From source file:com.ge.predix.uaa.token.lib.FastTokenServices.java
private void verifyTimeWindow(final Map<String, Object> claims) { Date iatDate = getIatDate(claims); Date expDate = getExpDate(claims); Date currentDate = new Date(); if (iatDate != null && iatDate.after(currentDate)) { throw new InvalidTokenException(String.format( "Token validity window is in the future. Token is issued at [%s]. Current date is [%s]", iatDate.toString(), currentDate.toString())); }/*from ww w .j a v a 2 s . c om*/ if (expDate != null && expDate.before(currentDate)) { throw new InvalidTokenException( String.format("Token is expired. Expiration date is [%s]. Current date is [%s]", expDate.toString(), currentDate.toString())); } }
From source file:com.qcadoo.mes.orders.hooks.OrderHooks.java
public boolean validateDates(final DataDefinition orderDD, final Entity order) { Date effectiveDateFrom = order.getDateField(OrderFields.EFFECTIVE_DATE_FROM); Date effectiveDateTo = order.getDateField(OrderFields.EFFECTIVE_DATE_TO); if ((effectiveDateFrom != null) && (effectiveDateTo != null) && effectiveDateTo.before(effectiveDateFrom)) { order.addError(orderDD.getField(OrderFields.EFFECTIVE_DATE_TO), "orders.validate.global.error.effectiveDateTo"); return false; }/*from www .j a v a2 s .c o m*/ return true; }
From source file:com.ibm.bluemix.smartveggie.controller.VendorController.java
@RequestMapping(value = "/assignSubOutlet.html", method = RequestMethod.GET) public String vendorAllocateSubOutlet(HttpServletRequest request, @ModelAttribute("suboutletvendorAllocation") SubOutletVendorAllocationDTO suboutletvendorAllocation, Map<String, Object> model) { System.out.println(suboutletvendorAllocation.getSmartCityCode()); System.out.println(suboutletvendorAllocation.getSmartOutletCode()); System.out.println(suboutletvendorAllocation.getSuboutletCode()); System.out.println(suboutletvendorAllocation.getSuboutletAllocatedFrom()); System.out.println(suboutletvendorAllocation.getVendorLicenseNo()); System.out.println(suboutletvendorAllocation.getVendorUsername()); List<SmartCityDTO> smartCityLists = adminService.retreiveSmartCities(); List<OutletDTO> outletLists = outletService.getOutlets(); List<SubOutletDTO> suboutletLists = outletService.getSubOutlets(); model.put("smartCityLists", smartCityLists); model.put("outletLists", outletLists); model.put("suboutletLists", suboutletLists); String dateFrom = suboutletvendorAllocation.getSuboutletAllocatedFrom(); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); Date leaseDateFrom = null;// w w w . j a va2s . c om Date leaseDateTo = null; try { leaseDateFrom = dateFormat.parse(dateFrom); //System.out.println("Lease Date From ...."+leaseDateFrom); Calendar cal = Calendar.getInstance(); cal.setTime(leaseDateFrom); cal.add(Calendar.MONTH, 1); leaseDateTo = cal.getTime(); //System.out.println("Lease To Date ...."+cal.getTime()); //Convert from leased to date to String //System.out.println("Date to...."+dateFormat.format(leaseDateTo)); suboutletvendorAllocation.setSuboutletAllocatedTo(dateFormat.format(leaseDateTo)); } catch (Exception e) { e.printStackTrace(); } subOutletVendorAllocationService.allocateSubOutlet(suboutletvendorAllocation); HttpSession session = request.getSession(); UserDTO userDTO = (UserDTO) session.getAttribute("loginUserForm"); userDTO = userService.getUser(userDTO.getUserName(), userDTO.getPassword()); model.put("userDTO", userDTO); List<SubOutletVendorAllocationDTO> subOutletVendorAllocationList = subOutletVendorAllocationService .retrieveAllocatedSubOutlet(); //model.put("subOutletVendorAllocationList",subOutletVendorAllocationList); List<SubOutletVendorAllocationDTO> vendorAllocationList = new ArrayList<SubOutletVendorAllocationDTO>(); if (subOutletVendorAllocationList != null) { for (SubOutletVendorAllocationDTO vendorAlloc : subOutletVendorAllocationList) { if (vendorAlloc.getVendorUsername() != null && vendorAlloc.getVendorUsername().equalsIgnoreCase(userDTO.getUserName())) { vendorAllocationList.add(vendorAlloc); } } } model.put("vendorAllocationList", vendorAllocationList); List<SubOutletVendorAllocationDTO> subOutletNotAvailableList = new ArrayList<SubOutletVendorAllocationDTO>(); //Get only those suboutlet whose lease end date is less than current date Date currentDate = Calendar.getInstance().getTime(); dateFormat = new SimpleDateFormat("dd/MM/yyyy"); if (subOutletVendorAllocationList != null) { for (SubOutletVendorAllocationDTO allocation : subOutletVendorAllocationList) { String allocationEndDate = allocation.getSuboutletAllocatedTo(); Date allocEndDate = null; try { allocEndDate = dateFormat.parse(allocationEndDate); if (allocEndDate.before(currentDate)) { System.out.println("Allocation already ended...."); //subOutletAvailableList.add(allocation); } else { subOutletNotAvailableList.add(allocation); System.out.println("Already allocation to vendor...."); } } catch (Exception e) { e.printStackTrace(); } } } List<SubOutletDTO> subOutletAvailableList = new ArrayList<SubOutletDTO>(); for (SubOutletDTO suboutlet : suboutletLists) { String smartCity = suboutlet.getSubOutletCityCode(); String smartOutlet = suboutlet.getOutletCode(); String smartSuboutlet = suboutlet.getSubOutletCode(); boolean notAvailable = false; for (SubOutletVendorAllocationDTO suboutletNotAvailable : subOutletNotAvailableList) { String smartCityNotAvailable = suboutletNotAvailable.getSmartCityCode(); String smartCityOutletNotAvailable = suboutletNotAvailable.getSmartOutletCode(); String smartCitySuboutletNotAvailable = suboutletNotAvailable.getSuboutletCode(); if (smartCity.equalsIgnoreCase(smartCityNotAvailable) && smartOutlet.equalsIgnoreCase(smartCityOutletNotAvailable) && smartSuboutlet.equalsIgnoreCase(smartCitySuboutletNotAvailable)) { //Do nothing as this outlet is unavailable notAvailable = true; break; } } if (!notAvailable) { subOutletAvailableList.add(suboutlet); } System.out.println("suboutlet available list..." + subOutletAvailableList); } model.put("subOutletAvailableList", subOutletAvailableList); return "admin/leaseSubOutlet"; }
From source file:com.ibm.bluemix.smartveggie.controller.VendorController.java
@RequestMapping(value = "/unassignSubOutlet.html", method = RequestMethod.GET) public String vendorDeallocateSubOutlet(HttpServletRequest request, @ModelAttribute("suboutletvendorAllocation") SubOutletVendorAllocationDTO suboutletvendorAllocation, Map<String, Object> model) { System.out.println(suboutletvendorAllocation.getSmartCityCode()); System.out.println(suboutletvendorAllocation.getSmartOutletCode()); System.out.println(suboutletvendorAllocation.getSuboutletCode()); System.out.println(suboutletvendorAllocation.getSuboutletAllocatedFrom()); System.out.println(suboutletvendorAllocation.getVendorLicenseNo()); System.out.println(suboutletvendorAllocation.getVendorUsername()); List<SmartCityDTO> smartCityLists = adminService.retreiveSmartCities(); List<OutletDTO> outletLists = outletService.getOutlets(); List<SubOutletDTO> suboutletLists = outletService.getSubOutlets(); model.put("smartCityLists", smartCityLists); model.put("outletLists", outletLists); model.put("suboutletLists", suboutletLists); String dateFrom = suboutletvendorAllocation.getSuboutletAllocatedFrom(); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); Date leaseDateFrom = null;// w w w. j ava 2 s.com Date leaseDateTo = null; try { leaseDateFrom = dateFormat.parse(dateFrom); //System.out.println("Lease Date From ...."+leaseDateFrom); Calendar cal = Calendar.getInstance(); cal.setTime(leaseDateFrom); cal.add(Calendar.MONTH, 1); leaseDateTo = cal.getTime(); //System.out.println("Lease To Date ...."+cal.getTime()); //Convert from leased to date to String //System.out.println("Date to...."+dateFormat.format(leaseDateTo)); suboutletvendorAllocation.setSuboutletAllocatedTo(dateFormat.format(leaseDateTo)); } catch (Exception e) { e.printStackTrace(); } subOutletVendorAllocationService.deallocateSubOutlet(suboutletvendorAllocation); HttpSession session = request.getSession(); UserDTO userDTO = (UserDTO) session.getAttribute("loginUserForm"); userDTO = userService.getUser(userDTO.getUserName(), userDTO.getPassword()); model.put("userDTO", userDTO); List<SubOutletVendorAllocationDTO> subOutletVendorAllocationList = subOutletVendorAllocationService .retrieveAllocatedSubOutlet(); //model.put("subOutletVendorAllocationList",subOutletVendorAllocationList); List<SubOutletVendorAllocationDTO> vendorAllocationList = new ArrayList<SubOutletVendorAllocationDTO>(); if (subOutletVendorAllocationList != null) { for (SubOutletVendorAllocationDTO vendorAlloc : subOutletVendorAllocationList) { if (vendorAlloc.getVendorUsername() != null && vendorAlloc.getVendorUsername().equalsIgnoreCase(userDTO.getUserName())) { vendorAllocationList.add(vendorAlloc); } } } model.put("vendorAllocationList", vendorAllocationList); List<SubOutletVendorAllocationDTO> subOutletNotAvailableList = new ArrayList<SubOutletVendorAllocationDTO>(); //Get only those suboutlet whose lease end date is less than current date Date currentDate = Calendar.getInstance().getTime(); dateFormat = new SimpleDateFormat("dd/MM/yyyy"); if (subOutletVendorAllocationList != null) { for (SubOutletVendorAllocationDTO allocation : subOutletVendorAllocationList) { String allocationEndDate = allocation.getSuboutletAllocatedTo(); Date allocEndDate = null; try { allocEndDate = dateFormat.parse(allocationEndDate); if (allocEndDate.before(currentDate)) { System.out.println("Allocation already ended...."); //subOutletAvailableList.add(allocation); } else { subOutletNotAvailableList.add(allocation); System.out.println("Already allocation to vendor...."); } } catch (Exception e) { e.printStackTrace(); } } } List<SubOutletDTO> subOutletAvailableList = new ArrayList<SubOutletDTO>(); for (SubOutletDTO suboutlet : suboutletLists) { String smartCity = suboutlet.getSubOutletCityCode(); String smartOutlet = suboutlet.getOutletCode(); String smartSuboutlet = suboutlet.getSubOutletCode(); boolean notAvailable = false; for (SubOutletVendorAllocationDTO suboutletNotAvailable : subOutletNotAvailableList) { String smartCityNotAvailable = suboutletNotAvailable.getSmartCityCode(); String smartCityOutletNotAvailable = suboutletNotAvailable.getSmartOutletCode(); String smartCitySuboutletNotAvailable = suboutletNotAvailable.getSuboutletCode(); if (smartCity.equalsIgnoreCase(smartCityNotAvailable) && smartOutlet.equalsIgnoreCase(smartCityOutletNotAvailable) && smartSuboutlet.equalsIgnoreCase(smartCitySuboutletNotAvailable)) { //Do nothing as this outlet is unavailable notAvailable = true; break; } } if (!notAvailable) { subOutletAvailableList.add(suboutlet); } System.out.println("suboutlet available list..." + subOutletAvailableList); } model.put("subOutletAvailableList", subOutletAvailableList); return "admin/leaseSubOutlet"; }
From source file:com.celements.blog.plugin.BlogPlugin.java
private void filterTimespan(List<Article> articles, String language, boolean withArchive, boolean archiveOnly, boolean withFutur, boolean futurOnly, XWikiContext context) { Date now = new Date(); List<Article> deleteArticles = new ArrayList<Article>(); for (Iterator<Article> artIter = articles.iterator(); artIter.hasNext();) { Article article = (Article) artIter.next(); Date archivedate = article.getArchiveDate(language); Date publishdate = article.getPublishDate(language); if (((archivedate != null) && archivedate.before(now)) && ((!withArchive && !archiveOnly) || futurOnly)) { deleteArticles.add(article); }//ww w .j av a2s .c om if (((publishdate != null) && publishdate.after(now)) && ((!withFutur && !futurOnly) || (archiveOnly && (!withFutur || (archivedate == null) || ((archivedate != null) && archivedate.after(now)))))) { deleteArticles.add(article); } if (((publishdate == null) || publishdate.before(now)) && ((archivedate == null) || archivedate.after(now)) && (archiveOnly || futurOnly)) { deleteArticles.add(article); } } for (Iterator<Article> delIter = deleteArticles.iterator(); delIter.hasNext();) { articles.remove(delIter.next()); } }
From source file:com.digitalpebble.stormcrawler.bolt.SiteMapParserBolt.java
private List<Outlink> parseSiteMap(String url, byte[] content, String contentType, Metadata parentMetadata) throws UnknownFormatException, IOException { crawlercommons.sitemaps.SiteMapParser parser = new crawlercommons.sitemaps.SiteMapParser(strictMode); URL sURL = new URL(url); AbstractSiteMap siteMap;// w ww .j a v a2s. c o m // let the parser guess what the mimetype is if (StringUtils.isBlank(contentType) || contentType.contains("octet-stream")) { siteMap = parser.parseSiteMap(content, sURL); } else { siteMap = parser.parseSiteMap(contentType, content, sURL); } List<Outlink> links = new ArrayList<>(); if (siteMap.isIndex()) { SiteMapIndex smi = (SiteMapIndex) siteMap; Collection<AbstractSiteMap> subsitemaps = smi.getSitemaps(); // keep the subsitemaps as outlinks // they will be fetched and parsed in the following steps Iterator<AbstractSiteMap> iter = subsitemaps.iterator(); while (iter.hasNext()) { AbstractSiteMap asm = iter.next(); String target = asm.getUrl().toExternalForm(); // build an absolute URL try { target = URLUtil.resolveURL(sURL, target).toExternalForm(); } catch (MalformedURLException e) { LOG.debug("MalformedURLException on {}", target); continue; } Date lastModified = asm.getLastModified(); if (lastModified != null) { // filter based on the published date if (filterHoursSinceModified != -1) { Calendar rightNow = Calendar.getInstance(); rightNow.add(Calendar.HOUR, -filterHoursSinceModified); if (lastModified.before(rightNow.getTime())) { LOG.info("{} has a modified date {} which is more than {} hours old", target, lastModified.toString(), filterHoursSinceModified); continue; } } } // apply filtering to outlinks target = urlFilters.filter(sURL, parentMetadata, target); if (StringUtils.isBlank(target)) continue; // configure which metadata gets inherited from parent Metadata metadata = metadataTransfer.getMetaForOutlink(target, url, parentMetadata); metadata.setValue(isSitemapKey, "true"); Outlink ol = new Outlink(target); ol.setMetadata(metadata); links.add(ol); LOG.debug("{} : [sitemap] {}", url, target); } } // sitemap files else { SiteMap sm = (SiteMap) siteMap; // TODO see what we can do with the LastModified info Collection<SiteMapURL> sitemapURLs = sm.getSiteMapUrls(); Iterator<SiteMapURL> iter = sitemapURLs.iterator(); while (iter.hasNext()) { SiteMapURL smurl = iter.next(); double priority = smurl.getPriority(); // TODO handle priority in metadata ChangeFrequency freq = smurl.getChangeFrequency(); // TODO convert the frequency into a numerical value and handle // it in metadata String target = smurl.getUrl().toExternalForm(); // build an absolute URL try { target = URLUtil.resolveURL(sURL, target).toExternalForm(); } catch (MalformedURLException e) { LOG.debug("MalformedURLException on {}", target); continue; } Date lastModified = smurl.getLastModified(); if (lastModified != null) { // filter based on the published date if (filterHoursSinceModified != -1) { Calendar rightNow = Calendar.getInstance(); rightNow.add(Calendar.HOUR, -filterHoursSinceModified); if (lastModified.before(rightNow.getTime())) { LOG.info("{} has a modified date {} which is more than {} hours old", target, lastModified.toString(), filterHoursSinceModified); continue; } } } // apply filtering to outlinks target = urlFilters.filter(sURL, parentMetadata, target); if (StringUtils.isBlank(target)) continue; // configure which metadata gets inherited from parent Metadata metadata = metadataTransfer.getMetaForOutlink(target, url, parentMetadata); metadata.setValue(isSitemapKey, "false"); Outlink ol = new Outlink(target); ol.setMetadata(metadata); links.add(ol); LOG.debug("{} : [sitemap] {}", url, target); } } return links; }
From source file:com.vaadin.addon.jpacontainer.demo.OrderView.java
private void doFilter() { Date from = (Date) filterFrom.getValue(); Date to = (Date) filterTo.getValue(); Object customerId = filterCustomer.getValue(); if (customerId == null && from == null && to == null) { getWindow().showNotification("Nothing to do"); return;//from ww w .j av a 2 s . c o m } orderContainer.removeAllContainerFilters(); if (customerId != null) { Customer c = customerContainer.getItem(customerId).getEntity(); orderContainer.addContainerFilter(new Equal("customer", c)); } if (from != null && to != null) { if (to.before(from)) { getWindow().showNotification("Please check the dates!", Notification.TYPE_WARNING_MESSAGE); return; } orderContainer.addContainerFilter(new Between("orderDate", from, to)); } else if (from != null) { orderContainer.addContainerFilter(new GreaterOrEqual("orderDate", from)); } else if (to != null) { orderContainer.addContainerFilter(new LessOrEqual("orderDate", to)); } orderContainer.applyFilters(); resetBtn.setEnabled(true); }
From source file:com.sube.daos.mongodb.StatisticDaoTest.java
private void generateUsages() throws InvalidSubeCardException, InvalidProviderException { for (int i = 0; i < usagesSize; i++) { SubeCardUsage usage = new SubeCardUsage(); usage.setCard((SubeCard) getRandom(cards)); Date randomDate = DateUtils.round( DateUtils.round(DateUtils.round(getRandomDate(FROM, TO), Calendar.SECOND), Calendar.MINUTE), Calendar.HOUR);//from w w w.j a v a 2 s .c om usage.setDatetime(randomDate); if ((randomDate.after(TO_DIFF) || DateUtils.isSameDay(randomDate, TO_DIFF)) && (randomDate.before(TO) || DateUtils.isSameDay(randomDate, TO))) { Long count = usages1.get(randomDate); if (count != null) { count++; } else { count = Long.valueOf(1l); } usages1.put(randomDate, count); } else if ((randomDate.after(FROM) || DateUtils.isSameDay(randomDate, FROM)) && (randomDate.before(FROM_DIFF) || DateUtils.isSameDay(randomDate, FROM_DIFF))) { Long count = usages2.get(randomDate); if (count != null) { count++; } else { count = Long.valueOf(1l); } usages2.put(randomDate, count); } if (random.nextInt() % 2 == 0) { //Charge Money usage.setMoney((random.nextDouble() + 0.1d) * MONEY_LAMBDA); // 3.1 // max, // min // 0.1 usage.setPerformer((Provider) getRandom(cashierProviders)); cardUsagesDao.chargeMoney(usage); } else { //Charge Service usage.setMoney((random.nextDouble() + 0.1d) * -MONEY_LAMBDA); // -3.1 // min, // max // -0.1 usage.setPerformer((Provider) getRandom(serviceProviders)); cardUsagesDao.chargeService(usage); Long travelsCount = travels.get(usage.getCard()); if (travelsCount == null) { travelsCount = Long.valueOf(1l); } else { travelsCount++; } travels.put(usage.getCard(), travelsCount); } Double totalMoney = usages.get(usage.getPerformer()); if (totalMoney == null) { usages.put(usage.getPerformer(), Math.abs(usage.getMoney())); } else { totalMoney += Math.abs(usage.getMoney()); usages.put(usage.getPerformer(), totalMoney); } registerMoneyExpended(usage); } }
From source file:dk.dma.epd.common.prototype.sensor.nmea.NmeaSensor.java
protected void handleReplay(String msg) { // Check if proprietary sentence if (!ProprietaryFactory.isProprietaryTag(msg)) { return;/*from w w w . jav a 2 s . c o m*/ } IProprietaryTag tag = ProprietaryFactory.parseTag(new SentenceLine(msg)); if (!(tag instanceof IProprietarySourceTag)) { return; } IProprietarySourceTag sourceTag = (IProprietarySourceTag) tag; if (sourceTag == null || sourceTag.getTimestamp() == null) { return; } Date timestamp = sourceTag.getTimestamp(); // Set replay time to current timestamp setReplayTime(timestamp); if (getDataStart() == null && getReplayStartDate() != null) { if (timestamp.before(getReplayStartDate())) { return; } } Date now = new Date(); setDataEnd(timestamp); if (getDataStart() == null) { setDataStart(timestamp); } if (getReplayStart() == null) { setReplayStart(now); } long elapsedData = timestamp.getTime() - getDataStart().getTime(); long elapsedReal = (now.getTime() - getReplayStart().getTime()) * getReplaySpeedup(); long diff = elapsedData - elapsedReal; if (diff > 500) { Util.sleep(diff / getReplaySpeedup()); } setReplayEnd(now); }