List of usage examples for java.util Date after
public boolean after(Date when)
From source file:com.android.loganalysis.item.LogcatItem.java
/** * {@inheritDoc}//from w ww. j ava 2 s . co m */ @Override public LogcatItem merge(IItem other) throws ConflictingItemException { if (this == other) { return this; } if (other == null || !(other instanceof LogcatItem)) { throw new ConflictingItemException("Conflicting class types"); } LogcatItem logcat = (LogcatItem) other; Date start = logcat.getStartTime().before(getStartTime()) ? logcat.getStartTime() : getStartTime(); Date stop = logcat.getStopTime().after(getStopTime()) ? logcat.getStopTime() : getStopTime(); Date overlapStart = logcat.getStartTime().after(getStartTime()) ? logcat.getStartTime() : getStartTime(); Date overlapStop = logcat.getStopTime().before(getStopTime()) ? logcat.getStopTime() : getStopTime(); // Make sure that all events in the overlapping span are ItemList mergedEvents = new ItemList(); for (MiscLogcatItem event : getEvents()) { final Date eventTime = event.getEventTime(); if (eventTime.after(overlapStart) && eventTime.before(overlapStop) && !logcat.getEvents().contains(event)) { throw new ConflictingItemException( "Event in first logcat not contained in " + "overlapping portion of other logcat."); } mergedEvents.add(event); } for (MiscLogcatItem event : logcat.getEvents()) { final Date eventTime = event.getEventTime(); if (eventTime.after(overlapStart) && eventTime.before(overlapStop)) { if (!getEvents().contains(event)) { throw new ConflictingItemException( "Event in first logcat not contained in " + "overlapping portion of other logcat."); } } else { mergedEvents.add(event); } } LogcatItem mergedLogcat = new LogcatItem(); mergedLogcat.setStartTime(start); mergedLogcat.setStopTime(stop); mergedLogcat.setAttribute(EVENTS, mergedEvents); return mergedLogcat; }
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 w w w . j av a 2s . co 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:edu.sjsu.cmpe275.project.service.SearchRoomAvailability.java
private boolean isAvailable(Room room, Date checkinDate, Date checkoutDate) { List<Reservation> reservations = room.getReservationList(); if (reservations == null) { return true; }//from w ww .jav a 2s. c o m //traverse all the reservation to check availability for (Reservation reservation : reservations) { Date inDate = reservation.getCheckinDate(); Date outDate = reservation.getCheckoutDate(); if ((inDate.getTime() == checkinDate.getTime()) || (outDate.getTime() == checkoutDate.getTime()) || (inDate.after(checkinDate) && inDate.before(checkoutDate)) || (outDate.after(checkinDate) && outDate.before(checkoutDate))) { return false; } } return true; }
From source file:net.audumla.climate.bom.BOMSimpleClimateForcastObserver.java
public boolean supportsDate(Date date) { Calendar c = Calendar.getInstance(); c.setTime(Time.getToday());// ww w .j a v a 2s . com return date.after(c.getTime()); }
From source file:com.inmobi.messaging.consumer.util.TestUtil.java
public static void prepareExpectedDeltaPck(Date fromTime, Date toTime, Map<Integer, PartitionCheckpoint> expectedDeltaPck, FileStatus file, Path streamDir, Set<Integer> partitionMinList, PartitionCheckpointList partitionCheckpointList, boolean isStart, boolean isFileCompleted) { Map<Integer, Date> chkTimeStampMap = new HashMap<Integer, Date>(); // prepare a checkpoint map prepareChkpointTimeMap(chkTimeStampMap, partitionMinList, partitionCheckpointList); Calendar current = Calendar.getInstance(); current.setTime(fromTime);//from w w w . j a v a 2s . com int lineNum; if (isFileCompleted) { lineNum = -1; } else { lineNum = 0; } if (isStart) { Calendar hourCal = Calendar.getInstance(); hourCal.setTime(fromTime); hourCal.add(Calendar.MINUTE, 60); Date hourTime = hourCal.getTime(); while (current.getTime().before(hourTime)) { int minute = current.get(Calendar.MINUTE); if (partitionMinList.contains(minute)) { Date chkTime = chkTimeStampMap.get(minute); if (chkTime == null || chkTime.before(current.getTime())) { expectedDeltaPck.put(Integer.valueOf(minute), new PartitionCheckpoint( DatabusStreamWaitingReader.getHadoopStreamFile(streamDir, current.getTime()), lineNum)); } } current.add(Calendar.MINUTE, 1); } } if (!isStart) { current.add(Calendar.MINUTE, 1); while (current.getTime().before(toTime)) { int minute = current.get(Calendar.MINUTE); if (partitionMinList.contains(minute)) { Date chkTime = chkTimeStampMap.get(minute); if (chkTime == null || !chkTime.after(current.getTime())) { expectedDeltaPck.put(Integer.valueOf(minute), new PartitionCheckpoint( DatabusStreamWaitingReader.getHadoopStreamFile(streamDir, current.getTime()), -1)); } } current.add(Calendar.MINUTE, 1); } } current.setTime(fromTime); if (file != null) { int minute = current.get(Calendar.MINUTE); expectedDeltaPck.put(Integer.valueOf(minute), new PartitionCheckpoint(DatabusStreamWaitingReader.getHadoopStreamFile(file), -1)); } else { int minute = current.get(Calendar.MINUTE); expectedDeltaPck.put(Integer.valueOf(minute), new PartitionCheckpoint( DatabusStreamWaitingReader.getHadoopStreamFile(streamDir, current.getTime()), -1)); } }
From source file:com.feilong.core.date.DateUtil.java
/** * <code>date</code>? <code>whenDate</code>?. * * @param date/*w ww . j a v a 2 s . co m*/ * * @param whenDate * * @return <code>date</code> null,false<br> * <code>when</code> null,<br> * ? <code>date.after(when)</code> * @see java.util.Date#after(Date) * @since 1.2.2 */ public static boolean isAfter(Date date, Date whenDate) { Validate.notNull(whenDate, "whenDate can't be null!"); return null == date ? false : date.after(whenDate); }
From source file:mitm.common.security.crl.CRLUtils.java
/** * Returns 0 if crl and otherCRL have similar validity (ie no one is newer than the other), * > 0 if crl is newer than otherCRL and < 0 if crl is older than otherCRL *//*from w w w . j a v a 2 s .c o m*/ public static int compare(X509CRL crl, X509CRL otherCRL) throws IOException, MissingDateException { BigInteger crlNumber = X509CRLInspector.getCRLNumber(crl); BigInteger otherCRLNumber = X509CRLInspector.getCRLNumber(crl); Date thisUpdate = crl.getThisUpdate(); Date otherThisUpdate = otherCRL.getThisUpdate(); if (thisUpdate == null || otherThisUpdate == null) { throw new MissingDateException("One of the CRLs has a missing thisUpdate."); } int cmp; if (crlNumber != null && otherCRLNumber != null) { cmp = crlNumber.compareTo(otherCRLNumber); if (cmp > 0) { if (thisUpdate.before(otherThisUpdate)) { logger.warn("According to CRL numbers a new CRL is found but thisUpdate is older."); } logger.debug("The CRL number is bigger and is therefore more recent."); } else if (cmp == 0) { /* * same CRL number but thisUpdate can be newer */ cmp = thisUpdate.compareTo(otherThisUpdate); if (cmp > 0) { logger.debug("The CRL numbers are equal but thisUpdate is newer."); } } else { if (thisUpdate.after(otherThisUpdate)) { logger.warn("According to CRL numbers this not a new CRL but thisUpdate is newer."); } } } else { /* * no CRL number so compare thisUpdate */ cmp = thisUpdate.compareTo(otherThisUpdate); if (cmp > 0) { logger.debug("A more recent CRL is found."); } } return cmp; }
From source file:net.yacy.cora.protocol.ResponseHeader.java
/** * Get the http field Date or now (if header date missing) * @return date message was created or now */// www. j av a 2s. c om public Date date() { if (this.date_cache_Date != null) return this.date_cache_Date; final Date d = headerDate(HeaderFramework.DATE); final Date now = new Date(); this.date_cache_Date = (d == null) ? now : d.after(now) ? now : d; return this.date_cache_Date; }
From source file:admin.jmx.SimpleJobExecutionMetrics.java
private StepExecution getLatestStepExecution(JobExecution jobExecution) { Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions(); StepExecution stepExecution = null;//from w ww.jav a 2 s .c o m if (!stepExecutions.isEmpty()) { Date latest = new Date(0L); for (StepExecution candidate : stepExecutions) { Date stepDate = candidate.getEndTime(); stepDate = stepDate == null ? new Date() : stepDate; if (stepDate.after(latest)) { latest = stepDate; stepExecution = candidate; } else if (stepExecution != null && stepDate.equals(latest) && candidate.getId() > stepExecution.getId()) { // Tie breaker using ID stepExecution = candidate; } } } return stepExecution; }