List of usage examples for java.util Date before
public boolean before(Date when)
From source file:br.com.bluesoft.pronto.model.Sprint.java
public List<Date> getDias() { final List<Date> dias = new LinkedList<Date>(); Date atual = getDataInicial(); while (atual.before(dataFinal)) { dias.add(atual);//from www . j ava 2 s .c o m atual = DateUtil.add(atual, 1); } dias.add(dataFinal); return dias; }
From source file:ch.astina.hesperid.agentbundle.Agent.java
private boolean serverHasObserverModifications(Date lastUpdatedObserver, Date lastUpdatedInformationOnClient) { return lastUpdatedObserver != null && (lastUpdatedInformationOnClient == null || lastUpdatedInformationOnClient.before(lastUpdatedObserver)); }
From source file:com.salesmanager.core.util.ProductUtil.java
public static String formatHTMLProductPrice(Locale locale, String currency, Product view, boolean showDiscountDate, boolean shortDiscountFormat) { if (currency == null) { log.error("Currency is null ..."); return "-N/A-"; }//from ww w.ja v a 2 s .c o m int decimalPlace = 2; String prefix = ""; String suffix = ""; Map currenciesmap = RefCache.getCurrenciesListWithCodes(); Currency c = (Currency) currenciesmap.get(currency); // regular price BigDecimal bdprodprice = view.getProductPrice(); Date dt = new Date(); // discount price java.util.Date spdate = null; java.util.Date spenddate = null; BigDecimal bddiscountprice = null; Special special = view.getSpecial(); 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 = view.getPrices(); if (prices != null) { Iterator pit = prices.iterator(); while (pit.hasNext()) { ProductPrice pprice = (ProductPrice) pit.next(); if (pprice.isDefaultPrice()) { pprice.setLocale(locale); suffix = pprice.getPriceSuffix(); bddiscountprice = null; spdate = null; spenddate = null; bdprodprice = pprice.getProductPriceAmount(); ProductPriceSpecial ppspecial = pprice.getSpecial(); if (ppspecial != null) { if (ppspecial.getProductPriceSpecialStartDate() != null && ppspecial.getProductPriceSpecialEndDate() != null) { spdate = ppspecial.getProductPriceSpecialStartDate(); spenddate = ppspecial.getProductPriceSpecialEndDate(); } bddiscountprice = ppspecial.getProductPriceSpecialAmount(); } break; } } } double fprodprice = 0; ; if (bdprodprice != null) { fprodprice = bdprodprice.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP).doubleValue(); } // regular price String String regularprice = CurrencyUtil.displayFormatedCssAmountWithCurrency(bdprodprice, currency); // discount price String String discountprice = null; String savediscount = null; if (bddiscountprice != null && (spdate != null && spdate.before(new Date(dt.getTime())) && spenddate.after(new Date(dt.getTime())))) { double fdiscountprice = bddiscountprice.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP).doubleValue(); discountprice = CurrencyUtil.displayFormatedAmountWithCurrency(bddiscountprice, currency); double arith = fdiscountprice / fprodprice; double fsdiscount = 100 - arith * 100; Float percentagediscount = new Float(fsdiscount); savediscount = String.valueOf(percentagediscount.intValue()); } StringBuffer p = new StringBuffer(); p.append("<div class='product-price'>"); if (discountprice == null) { p.append("<div class='product-price-price' style='width:50%;float:left;'>"); p.append(regularprice); if (!StringUtils.isBlank(suffix)) { p.append(suffix).append(" "); } p.append("</div>"); p.append("<div class='product-line'> </div>"); } else { p.append("<div style='width:50%;float:left;'>"); p.append("<strike>").append(regularprice); if (!StringUtils.isBlank(suffix)) { p.append(suffix).append(" "); } p.append("</strike>"); p.append("</div>"); p.append("<div style='width:50%;float:right;'>"); p.append("<font color='red'>").append(discountprice); if (!StringUtils.isBlank(suffix)) { p.append(suffix).append(" "); } p.append("</font>"); if (!shortDiscountFormat) { p.append("<br>").append("<font color='red' style='font-size:75%;'>") .append(LabelUtil.getInstance().getText(locale, "label.generic.save")).append(": ") .append(savediscount) .append(LabelUtil.getInstance().getText(locale, "label.generic.percentsign")).append(" ") .append(LabelUtil.getInstance().getText(locale, "label.generic.off")).append("</font>"); } if (showDiscountDate && spenddate != null) { p.append("<br>").append(" <font style='font-size:65%;'>") .append(LabelUtil.getInstance().getText(locale, "label.generic.until")).append(" ") .append(DateUtil.formatDate(spenddate)).append("</font>"); } p.append("</div>").toString(); } p.append("</div>"); return p.toString(); }
From source file:br.com.ingenieux.mojo.beanstalk.cmd.env.waitfor.WaitForEnvironmentCommand.java
boolean timedOutP(Date expiresAt) throws MojoExecutionException { return expiresAt.before(new Date(System.currentTimeMillis())); }
From source file:com.venilnoronha.dzone.feed.web.LinksRSSController.java
@RequestMapping(value = "/rss/links", method = RequestMethod.GET) public ModelAndView linksRssByLastModified(HttpEntity<byte[]> requestEntity, HttpServletRequest request, HttpServletResponse response) throws ParseException { HttpUtils.logUserIP("LinksRSS", request); String lastModified = requestEntity.getHeaders().getFirst("If-Modified-Since"); if (lastModified == null) { lastModified = requestEntity.getHeaders().getFirst("If-None-Match"); }//from w ww .ja v a 2s . c o m PageRequest page = new PageRequest(0, feedSize, Direction.DESC, "linkDate"); Page<Link> linkPage; if (lastModified != null) { Date lastModifiedDt = HTTP_FORMAT.parse(lastModified); linkPage = linksRepository.findByLinkDateBetween(lastModifiedDt, new Date(), page); } else { linkPage = linksRepository.findAll(page); } Iterator<Link> linksIter = linkPage.iterator(); List<Link> links = new ArrayList<>(); Date newLastModified = null; while (linksIter.hasNext()) { Link link = linksIter.next(); Date linkDate = link.getLinkDate(); if (newLastModified == null || newLastModified.before(linkDate)) { newLastModified = linkDate; } links.add(link); } if (links.isEmpty() && lastModified != null) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return null; } else { response.setHeader("ETag", HTTP_FORMAT.format(newLastModified)); response.setHeader("Last-Modified", HTTP_FORMAT.format(newLastModified)); ModelAndView mav = new ModelAndView(); mav.setView(new LinksRSSView(links)); return mav; } }
From source file:com.smartitengineering.cms.spi.impl.content.PersistentVariationProviderImpl.java
@Override public Variation getVariation(String varName, Content content, Field field) { if (StringUtils.isBlank(varName) || field == null || content == null) { logger.info("Variation name or field or content is null or blank!"); return null; }/*w ww. j a v a 2 s . c o m*/ final TemplateId id = new TemplateId(); id.setId(new StringBuilder(content.getContentId().toString()).append(':').append(field.getName()) .append(':').append(varName).toString()); PersistentVariation cachedVar = readDao.getById(id); boolean update = false; if (cachedVar != null) { update = true; Date cachedDate = cachedVar.getVariation().getLastModifiedDate(); VariationTemplate template = SmartContentAPI.getInstance().getWorkspaceApi() .getVariationTemplate(content.getContentId().getWorkspaceId(), varName); Date lastModified = content.getLastModifiedDate(); if (template != null) { final Date lastModifiedDate = template.getLastModifiedDate(); if (lastModified.before(lastModifiedDate)) { lastModified = lastModifiedDate; } } if (cachedDate.before(lastModified)) { cachedVar = null; } } if (cachedVar == null) { Variation var = mainProvider.getVariation(varName, content, field); cachedVar = new PersistentVariation(); cachedVar.setId(id); cachedVar.setVariation(var); if (update) { writeDao.update(cachedVar); Event<Variation> event = SmartContentAPI.getInstance().getEventRegistrar() .<Variation>createEvent(EventType.UPDATE, Type.VARIATION, var); SmartContentAPI.getInstance().getEventRegistrar().notifyEventAsynchronously(event); } else { writeDao.save(cachedVar); Event<Variation> event = SmartContentAPI.getInstance().getEventRegistrar() .<Variation>createEvent(EventType.CREATE, Type.VARIATION, var); SmartContentAPI.getInstance().getEventRegistrar().notifyEventAsynchronously(event); } } return cachedVar.getVariation(); }
From source file:com.feilong.core.date.DateUtil.java
/** * <code>date</code>? <code>whenDate</code>?. * * @param date//from ww w .ja va2 s . co m * * @param whenDate * * @return <code>date</code> null,false<br> * <code>whenDate</code> null,<br> * ? <code>date.before(when)</code> * @see java.util.Date#before(Date) * @since 1.2.2 */ public static boolean isBefore(Date date, Date whenDate) { Validate.notNull(whenDate, "whenDate can't be null!"); return null == date ? false : date.before(whenDate); }
From source file:com.google.livingstories.server.dataservices.entities.LivingStoryEntity.java
/** * Return the contents of the last summary revision that was saved before a given time. * If the provided time is null, returns the contents of the latest summary revision. *///from ww w .jav a2 s . c o m public String getLastSummaryRevisionBeforeTime(Date time) { if (time == null) { return getSummary(); } String lastRevisionContent = ""; for (Summary revision : summaryRevisions) { Date revisionTimestamp = revision.getTimestamp(); if (revisionTimestamp.before(time)) { lastRevisionContent = revision.getContent(); } else { break; } } return lastRevisionContent; }
From source file:licenceexecuter.LicenceExecuter.java
private void run() throws Throwable { Date atualDate = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); ObKeyExecuter obKey = ControllerKey.decrypt(properties.getProperty("key")); if (atualDate.before(obKey.getDataLicenca())) { JOptionPane.showMessageDialog(null, "SUA LICENA INICIA DIA: " + sdf.format(obKey.getDataLicenca()), "ATENO", JOptionPane.ERROR_MESSAGE); return;/*w ww .ja v a 2 s .c om*/ } if (atualDate.after(obKey.getUltimaDataVerificada())) { try { if (atualDate.before(obKey.getDataValidade())) { Calendar calendar = Calendar.getInstance(); calendar.setTime(obKey.getDataValidade()); calendar.add(Calendar.DAY_OF_MONTH, -6); if (atualDate.after(calendar.getTime())) { String msg = String.format( "SUA LICENA VENCE NO DIA %s ENTRE COM A NOVA CHAVE OU CONTINUE.", sdf.format(obKey.getDataValidade())); JDialogRegister jDialogRegister = new JDialogRegister(msg); jDialogRegister.setVisible(true); if (jDialogRegister.getNewKey() != null && !jDialogRegister.getNewKey().isEmpty()) { ObKeyExecuter ob2 = register(jDialogRegister.getNewKey()); obKey = ob2 == null ? obKey : ob2; } } } else { String msg = String.format( "SUA LICENA VENCEU NO DIA %s ENTRE COM A NOVA CHAVE OU CONTINUE PARA SAIR.", sdf.format(obKey.getDataValidade())); JDialogRegister jDialogRegister = new JDialogRegister(msg); jDialogRegister.setVisible(true); if (jDialogRegister.getNewKey() != null && !jDialogRegister.getNewKey().isEmpty()) { ObKeyExecuter ob2 = register(jDialogRegister.getNewKey()); if (ob2 == null) { return; } obKey = ob2; } else { return; } } executeProgram(obKey); } finally { obKey.setUltimaDataVerificada(atualDate); updateKey(obKey); } } else { JOptionPane.showMessageDialog(null, "POSS?VEL ALTERAO NO RELGIO DO SISTEMA! VERIFIQUE", "ATENO", JOptionPane.ERROR_MESSAGE); } }
From source file:eionet.transfer.dao.MetadataServiceJdbc.java
@Override public List<Upload> getUnexpired(Date expireDate) { List<Upload> allUploads = getAll(); List<Upload> uploadList = new ArrayList<Upload>(); for (Upload upload : allUploads) { if (expireDate.before(upload.getExpires())) { uploadList.add(upload);// w ww. j ava 2 s . c o m } } return uploadList; }