List of usage examples for java.util Date after
public boolean after(Date when)
From source file:com.norconex.commons.lang.time.YearMonthDayInterval.java
/** * Whether the date falls between this interval * (inclusive endpoints).// w ww. ja v a 2 s . co m * @param date a date * @return <code>true</code> if the date is included in this interval */ public boolean contains(Date date) { Date startDate = start.toDate(); Date endDate = end.toDate(); if (startDate.after(date)) { return false; } if (endDate.before(date)) { return false; } return true; }
From source file:net.mikaboshi.intra_mart.tools.log_stats.report.SessionMap.java
public void putFirstAccessDate(String sessionId, Date date) { if (!isValidId(sessionId) || date == null) { return;/*from w ww . j a v a 2 s. com*/ } Date prev = this.firstAccessSessionMap.get(sessionId); if (prev == null || prev.after(date)) { this.firstAccessSessionMap.put(sessionId, date); } }
From source file:com.google.cloud.backend.spi.ProspectiveSearchServlet.java
/** * Checks if subscriptions for the device are active. * * @param deviceId A unique device identifier * @return True, if subscriptions are active; False, the otherwise *//* ww w. j ava 2 s . co m*/ private boolean isSubscriptionActive(String deviceId) { Date lastDeleteAll = backendConfigManager.getLastSubscriptionDeleteAllTime(); // If the admin never requested to delete all subscriptions, then this device subscription is // still active. if (lastDeleteAll == null) { return true; } Entity deviceEntity = deviceSubscription.get(deviceId); if (deviceEntity == null) { return false; } Date latestSubscriptionTime = (Date) deviceEntity.getProperty(DeviceSubscription.PROPERTY_TIMESTAMP); return latestSubscriptionTime.after(lastDeleteAll); }
From source file:com.mycompany.CRMFly.serviceLayer.ClientsServiceImpl.java
@Transactional public Map<Date, Double> getSumsFotDates(Clients client) { Long id = client.getId();//w w w . j a va 2 s. co m Calendar calendar = new GregorianCalendar(); Integer monthDifference = 0; if (calendar.get(Calendar.MONTH) == Calendar.JANUARY || calendar.get(Calendar.MONTH) == Calendar.APRIL || calendar.get(Calendar.MONTH) == Calendar.JULY || calendar.get(Calendar.MONTH) == Calendar.OCTOBER) { monthDifference = 0; } else if (calendar.get(Calendar.MONTH) == Calendar.FEBRUARY || calendar.get(Calendar.MONTH) == Calendar.MAY || calendar.get(Calendar.MONTH) == Calendar.AUGUST || calendar.get(Calendar.MONTH) == Calendar.NOVEMBER) { monthDifference = -1; } else if (calendar.get(Calendar.MONTH) == Calendar.MARCH || calendar.get(Calendar.MONTH) == Calendar.JUNE || calendar.get(Calendar.MONTH) == Calendar.SEPTEMBER || calendar.get(Calendar.MONTH) == Calendar.DECEMBER) monthDifference = -2; // Integer dayDifference = -calendar.get(Calendar.DAY_OF_MONTH); calendar.add(Calendar.MONTH, monthDifference); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); // calendar.add(Calendar.DAY_OF_MONTH, dayDifference-1); Date beginningOfQuarter = calendar.getTime(); Double thisQuarterSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackOne = calendar.getTime(); Double QuarterBackOneSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackTwo = calendar.getTime(); Double QuarterBackTwoSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackThree = calendar.getTime(); Double QuarterBackThreeSum = 0.0; List<Contracts> contracts = clientsDAO.getContractsForClient(id); HashMap<Date, Double> sums = new HashMap<Date, Double>(); for (Contracts contract : contracts) { Date date = contract.getBegin_date(); if (date.after(beginningOfQuarter)) thisQuarterSum += contract.getTotalSum(); else if (date.after(QuarterBackOne)) QuarterBackOneSum += contract.getTotalSum(); else if (date.after(QuarterBackTwo)) QuarterBackTwoSum += contract.getTotalSum(); else if (date.after(QuarterBackThree)) QuarterBackThreeSum += contract.getTotalSum(); } sums.put(beginningOfQuarter, thisQuarterSum); sums.put(QuarterBackOne, QuarterBackOneSum); sums.put(QuarterBackTwo, QuarterBackTwoSum); sums.put(QuarterBackThree, QuarterBackThreeSum); return sums; }
From source file:com.mycompany.CRMFly.serviceLayer.ProductsServiceImpl.java
@Transactional public Map<Date, Double> getSumsFotDates(Products product) { Long id = product.getId();/*from w w w . j a v a2 s.c om*/ Calendar calendar = new GregorianCalendar(); Integer monthDifference = 0; if (calendar.get(Calendar.MONTH) == Calendar.JANUARY || calendar.get(Calendar.MONTH) == Calendar.APRIL || calendar.get(Calendar.MONTH) == Calendar.JULY || calendar.get(Calendar.MONTH) == Calendar.OCTOBER) { monthDifference = 0; } else if (calendar.get(Calendar.MONTH) == Calendar.FEBRUARY || calendar.get(Calendar.MONTH) == Calendar.MAY || calendar.get(Calendar.MONTH) == Calendar.AUGUST || calendar.get(Calendar.MONTH) == Calendar.NOVEMBER) { monthDifference = -1; } else if (calendar.get(Calendar.MONTH) == Calendar.MARCH || calendar.get(Calendar.MONTH) == Calendar.JUNE || calendar.get(Calendar.MONTH) == Calendar.SEPTEMBER || calendar.get(Calendar.MONTH) == Calendar.DECEMBER) monthDifference = -2; Integer dayDifference = -calendar.get(Calendar.DAY_OF_MONTH); calendar.add(Calendar.MONTH, monthDifference); calendar.add(Calendar.DAY_OF_MONTH, dayDifference - 1); Date beginningOfQuarter = calendar.getTime(); Double thisQuarterSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackOne = calendar.getTime(); Double QuarterBackOneSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackTwo = calendar.getTime(); Double QuarterBackTwoSum = 0.0; calendar.add(Calendar.MONTH, -3); Date QuarterBackThree = calendar.getTime(); Double QuarterBackThreeSum = 0.0; List<PositionsInContract> positions = productsDAO.getContractPositionsForProduct(id); HashMap<Date, Double> sums = new HashMap<Date, Double>(); for (PositionsInContract position : positions) { Long posID = position.getId(); Contracts contract = productsDAO.getContractForPosition(posID); Date date = contract.getBegin_date(); if (date.after(beginningOfQuarter)) thisQuarterSum += position.getPrice() * position.getQuantity(); else if (date.after(QuarterBackOne)) QuarterBackOneSum += position.getPrice() * position.getQuantity(); else if (date.after(QuarterBackTwo)) QuarterBackTwoSum += position.getPrice() * position.getQuantity(); else if (date.after(QuarterBackThree)) QuarterBackThreeSum += position.getPrice() * position.getQuantity(); } sums.put(beginningOfQuarter, thisQuarterSum); sums.put(QuarterBackOne, QuarterBackOneSum); sums.put(QuarterBackTwo, QuarterBackTwoSum); sums.put(QuarterBackThree, QuarterBackThreeSum); return sums; }
From source file:com.qcadoo.model.internal.validators.RangeValidator.java
private boolean validateDateRange(final FieldDefinition fieldDefinition, final Date value, final Entity validatedEntity) { if (from != null && ((!inclusively && !value.after((Date) from)) || (inclusively && value.before((Date) from)))) { addToSmallError(fieldDefinition, validatedEntity); return false; }/*w ww. j a v a 2 s . c o m*/ if (to != null && ((!inclusively && !value.before((Date) to)) || (inclusively && value.after((Date) to)))) { addToLargeError(fieldDefinition, validatedEntity); return false; } return true; }
From source file:com.openhr.UploadFile.java
private boolean isLicenseActive(Date currentDate, Date endDate) { if (currentDate.after(endDate)) { // License has expired return false; }//from w ww . j av a 2 s . c om return true; }
From source file:org.openmrs.module.radiology.web.controller.PortletsController.java
/** * Return true if end date is before start date * //from w w w . j a v a2 s . c om * @param startDate start date of the date range * @param endDate end date of the date range * @return true if end date is before start date * @should return true if end date is after start date * @should return false if end date is not after start date * @should return false with given start date but end date null * @should return false with given end date but start date null * @should return false with given end date and end date null */ private boolean isEndDateBeforeStartDate(Date startDate, Date endDate) { if (startDate != null && endDate != null) { if (startDate.after(endDate)) { return true; } } return false; }
From source file:de.slub.fedora.oai.OaiHarvester.java
private boolean isValidResumptionToken(String token, Date expires) { return token != null && !token.isEmpty() && (expires == null || expires.after(now())); }
From source file:dk.cafeanalog.AnalogDownloader.java
public Opening getCurrentOpening() throws JSONException, ParseException, IOException { if (System.currentTimeMillis() - mLastGet > TIME_BETWEEN_DOWNLOADS || mOpeningsCache == null) { getOpenings();/* w ww . j ava 2 s.com*/ } Date now = new Date(System.currentTimeMillis()); for (Opening opening : mOpeningsCache) { if (now.after(opening.getOpen()) && now.before(opening.getClose())) { return opening; } } return null; }