Example usage for java.util Date after

List of usage examples for java.util Date after

Introduction

In this page you can find the example usage for java.util Date after.

Prototype

public boolean after(Date when) 

Source Link

Document

Tests if this date is after the specified date.

Usage

From source file:com.seajas.search.profiler.task.FeedInjectionTask.java

/**
 * {@inheritDoc}/*  w ww  .j  a va  2  s. c o  m*/
 */
@Override
public void inject(final String triggerName, final Long intervalTotal,
        final InjectionJobInterrupted interrupted) {
    Date currentTime = new Date();

    List<Feed> enabledFeeds = getInjectableFeeds(triggerName, intervalTotal, currentTime);

    // Only log when we're not doing distributed injection - so to not get this every second

    if (logger.isInfoEnabled() && intervalTotal == null)
        logger.info("Performing feed injection under trigger '" + triggerName + "' (" + enabledFeeds.size()
                + " feed" + (enabledFeeds.size() != 1 ? "s" : "") + ")");

    // We report on the number of feeds first, and then move on to potentially canceling the operation

    if (Boolean.getBoolean("profiler.indexing.disabled")) {
        if (logger.isInfoEnabled())
            logger.info(
                    "Indexing has been explicitly disabled using 'profiler.indexing.disabled=true'. Skipping injection.");

        return;
    }

    for (Feed feed : enabledFeeds) {
        if (interrupted.isInterrupted()) {
            logger.warn("This job was interrupted - not continuing with feed injection");

            break;
        }

        // Mark this feed's injection date (ahead of the actual injection - but then this is not such a critical matter)

        profilerService.updateFeedLastInjected(feed.getId(), currentTime);

        // Determine whether this feed falls within the anonymization run from / until range

        if (feed.getFeedAnonymization() != null) {
            Date currentDate = Calendar.getInstance().getTime(),
                    runFrom = feed.getFeedAnonymization().getRunFrom(),
                    runUntil = feed.getFeedAnonymization().getRunUntil();

            if ((runFrom != null && currentDate.before(runFrom))
                    || (runUntil != null && currentDate.after(runUntil))) {
                logger.info("The feed with name '" + feed.getName()
                        + "' falls outside of its anonymization run from/until date - skipping");

                continue;
            }
        }

        // Create a map out of the feed result parameters

        Map<String, String> resultParameters = new HashMap<String, String>();

        if (feed.getFeedResultParameters() != null && feed.getFeedResultParameters().size() > 0)
            for (FeedResultParameter feedResultParameter : feed.getFeedResultParameters()) {
                if (resultParameters.containsKey(feedResultParameter.getFieldName()))
                    logger.warn("The result map already contains a parameter named '"
                            + feedResultParameter.getFieldName() + "' - it will be overwritten");

                resultParameters.put(feedResultParameter.getFieldName(), feedResultParameter.getFieldValue());
            }

        // Now inject each feed URL

        for (FeedUrl feedUrl : feed.getFeedUrls()) {
            if (interrupted.isInterrupted()) {
                logger.warn("This job was interrupted - not continuing with feed injection");

                break;
            }

            try {
                Long feedDelay = 0L, resultDelay = 0L;

                // Determine the feed-URL specific anonymization settings

                if (feed.getFeedAnonymization() != null) {
                    // Determine the feed delay

                    feedDelay = feed.getFeedAnonymization() != null
                            && feed.getFeedAnonymization().getFeedDelay() != null
                                    ? feed.getFeedAnonymization().getFeedDelay()
                                    : 0L;

                    if (feed.getFeedAnonymization().getIsFeedDelayRandomized())
                        feedDelay = (long) randomGenerator
                                .nextInt(feedDelay.intValue() - RANDOM_RANGE_MINIMUM + 1)
                                + RANDOM_RANGE_MINIMUM;

                    // Don't randomize the result delay here, but instead do this on the contender-side

                    resultDelay = feed.getFeedAnonymization() != null
                            && feed.getFeedAnonymization().getFeedElementDelay() != null
                                    ? feed.getFeedAnonymization().getFeedElementDelay()
                                    : 0L;
                }

                // Perform the optional authentication step

                String authenticatedUrl = feedUrl.getUrl();
                Map<String, String> authenticatedResultParameters = resultParameters;

                if (feed.getFeedConnection() != null) {
                    if (feed.getFeedConnection().getAuthenticationStrategy() != null) {
                        AuthenticationResult authenticationResult = profilerService.applyAuthenticationStrategy(
                                feed.getFeedConnection().getAuthenticationStrategy(), authenticatedUrl,
                                authenticatedResultParameters);

                        authenticatedUrl = authenticationResult.getUrl();
                        authenticatedResultParameters = authenticationResult.getResultParameters();
                    }
                }

                URI uri = new URI(authenticatedUrl);
                String hostname = StringUtils.hasText(uri.getHost()) ? uri.getHost().replace("www.", "")
                        : "localhost";

                logger.info("Injecting feed with name '" + feed.getName() + "' and URI '" + uri
                        + "' into bridge layer");

                // Determine which of the result parameters to turn into headers

                Map<String, String> resultHeaders = null;

                if (StringUtils.hasText(resultMappingParameter) && StringUtils.hasText(resultMappingHeader)) {
                    if (!authenticatedResultParameters.containsKey(resultMappingParameter)) {
                        if (logger.isDebugEnabled())
                            logger.debug("Result mapping was requested, but result mapping parameter '"
                                    + resultMappingParameter
                                    + "' is not present in the result parameter map - not adding header '"
                                    + resultMappingHeader + "'");
                    } else {
                        resultHeaders = new HashMap<String, String>();

                        resultHeaders.put(resultMappingHeader,
                                authenticatedResultParameters.get(resultMappingParameter));
                    }
                }

                // Inject it into the queue

                com.seajas.search.bridge.jms.model.Feed resultFeed = new com.seajas.search.bridge.jms.model.Feed();

                resultFeed.setUri(uri);
                resultFeed.setId(feed.getId());
                resultFeed.setName(feed.getName());
                resultFeed.setHostname(hostname);
                resultFeed.setCollection(feed.getCollection());

                resultFeed.setFeedEncodingOverride(feed.getFeedEncodingOverride());
                resultFeed.setResultEncodingOverride(feed.getResultEncodingOverride());
                resultFeed.setLanguageOverride(feed.getLanguage());
                resultFeed.setSummaryBased(feed.getIsSummaryBased());

                resultFeed.setDelay(feedDelay);
                resultFeed.setElementDelay(resultDelay);
                resultFeed.setElementDelayRandomized(feed.getFeedAnonymization() != null
                        && Boolean.TRUE.equals(feed.getFeedAnonymization().getIsFeedElementDelayRandomized()));

                resultFeed.setUserAgent(determineUserAgent(feed));
                resultFeed.setUserAgentsOverride(feed.getFeedAnonymization() != null
                        ? feed.getFeedAnonymization().getPreferredUserAgents()
                        : null);
                resultFeed.setUserAgentsOverrideRandomized(feed.getFeedAnonymization() != null && Boolean.TRUE
                        .equals(feed.getFeedAnonymization().getIsPreferredUserAgentsRandomized()));

                resultFeed.setResultParameters(authenticatedResultParameters);
                resultFeed.setRetrievalRequestHeaders(resultHeaders);

                injectionService.inject(resultFeed, GroupIdDecorator.decorate(hostname), feedDelay);
            } catch (URISyntaxException e) {
                logger.error("The given " + (feed.getFeedConnection() != null
                        && feed.getFeedConnection().getAuthenticationStrategy() != null ? "(unauthenticated) "
                                : "")
                        + "feed URI '" + feedUrl.getUrl() + "' is not valid");
            }
        }
    }

    if (logger.isTraceEnabled())
        logger.trace("Finished feed injection for trigger '" + triggerName + "'");
}

From source file:com.neusoft.mid.clwapi.service.tacks.TacksServiceImpl.java

/**
 * ??.//from   w w w  .  j av a  2 s .  c  o m
 * 
 * @param token
 *            ?.
 * 
 * @param vin
 *            vin?.
 * 
 * @param startTime
 *            ,?yyyymmddhh24miss.
 * 
 * @param endTime
 *            ,?yyyymmddhh24miss.
 * @return ?.
 */
@Override
public Response getVinTacksDetail(String token, String vin, String startTime, String endTime) {
    vin = StringUtils.strip(vin);
    startTime = StringUtils.strip(startTime);
    endTime = StringUtils.strip(endTime);
    logger.info("-vin?:" + vin + ",:" + startTime + ",:"
            + endTime);

    Date sTime;
    Date eTime;
    try {
        sTime = TimeUtil.parseStringToDate(startTime, HttpConstant.TIME_FORMAT);
        eTime = TimeUtil.parseStringToDate(endTime, HttpConstant.TIME_FORMAT);
    } catch (ParseException e) {
        logger.info("-?" + startTime + "" + endTime
                + "??yyyyMMddHHmmss");
        throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
    }

    if (sTime.after(eTime)) {
        logger.info("-?" + startTime + "" + endTime
                + ",?");
        throw new ApplicationException(ErrorConstant.ERROR10003, Response.Status.BAD_REQUEST);
    }

    List<TackDetailInfo> resultList = getTackPonits(vin, startTime, endTime);
    if (CheckRequestParam.isEmpty(resultList)) {
        logger.info("-VIN:" + vin + "" + startTime + "-"
                + endTime + "");
        return Response.status(Response.Status.NO_CONTENT).header(HttpHeaders.CACHE_CONTROL, "no-store")
                .header("Pragma", "no-cache").build();
    }
    TackDetailResp resp = new TackDetailResp();
    resp.setResultList(resultList);

    return Response.ok(JacksonUtils.toJsonRuntimeException(resp)).header(HttpHeaders.CACHE_CONTROL, "no-store")
            .header("Pragma", "no-cache").build();
}

From source file:net.sf.logsaw.index.internal.LuceneIndexServiceImpl.java

private SynchronizationResult updateIndex(ILogResource log, final Date latestEntryDate,
        final IProgressMonitor monitor) throws CoreException {
    // Measure runtime
    final long startTime = System.currentTimeMillis();

    ARunWithIndexWriter<SynchronizationResult> runnable = new ARunWithIndexWriter<SynchronizationResult>() {

        /* (non-Javadoc)
         * @see net.sf.logsaw.index.impl.ARunWithIndexWriter#doRunWithIndexWriter(org.apache.lucene.index.IndexWriter, net.sf.logsaw.core.framework.ILogResource)
         *///from ww w  .j a va2s  . c  o  m
        @Override
        protected SynchronizationResult doRunWithIndexWriter(final IndexWriter writer, final ILogResource log)
                throws CoreException {
            ILogEntryCollector collector = new ALogEntryCollector(monitor) {

                /* (non-Javadoc)
                 * @see net.sf.logsaw.core.framework.support.ALogEntryCollector#doCollect(net.sf.logsaw.core.model.LogEntry)
                 */
                @Override
                protected boolean doCollect(final LogEntry entry) throws IOException {
                    final Document doc = new Document();
                    if (latestEntryDate != null) {
                        Date d = entry.get(log.getDialect().getFieldProvider().getTimestampField());
                        if (!d.after(latestEntryDate)) {
                            // Skip entry because it was already indexed
                            return false;
                        }
                    }

                    // Setup visitor
                    ILogEntryFieldVisitor visitor = new ILogEntryFieldVisitor() {

                        /* (non-Javadoc)
                         * @see net.sf.logsaw.core.model.ILogEntryFieldVisitor#visit(net.sf.logsaw.core.model.StringLogEntryField)
                         */
                        @Override
                        public void visit(StringLogEntryField fld) {
                            // Decide whether to analyze the field
                            if (fld.isAnalyzed()) {
                                doc.add(new TextField(fld.getKey(), fld.toIndexedValue(entry.get(fld)),
                                        Field.Store.YES));
                            } else {
                                doc.add(new StringField(fld.getKey(), fld.toIndexedValue(entry.get(fld)),
                                        Field.Store.YES));
                            }
                        }

                        /* (non-Javadoc)
                         * @see net.sf.logsaw.core.model.ILogEntryFieldVisitor#visit(net.sf.logsaw.core.model.LevelLogEntryField)
                         */
                        @Override
                        public void visit(LevelLogEntryField fld) {
                            Level lvl = entry.get(fld);
                            Assert.isTrue(lvl.getValue() > 0, "Level value must be a positive integer"); //$NON-NLS-1$
                            doc.add(new IntField(fld.getKey(), fld.toIndexedValue(lvl), Field.Store.YES));
                        }

                        /* (non-Javadoc)
                         * @see net.sf.logsaw.core.model.ILogEntryFieldVisitor#visit(net.sf.logsaw.core.model.DateLogEntryField)
                         */
                        @Override
                        public void visit(DateLogEntryField fld) {
                            doc.add(new LongField(fld.getKey(), fld.toIndexedValue(entry.get(fld)),
                                    Field.Store.YES));
                        }
                    };
                    for (ALogEntryField<?, ?> fld : log.getDialect().getFieldProvider().getAllFields()) {
                        if (entry.contains(fld)) {
                            fld.visit(visitor);
                        }
                    }
                    writer.addDocument(doc);
                    return true;
                }
            };

            if (log.getDialect().getFieldProvider().getTimestampField() == null) {
                // We have no barrier timestamp, so perform truncate to avoid duplicates
                truncate(log, writer);

                collector.addMessage(new Status(IStatus.INFO, IndexPlugin.PLUGIN_ID,
                        Messages.LuceneIndexService_info_autoTruncate_noTimestampField));
            } else if (!hasDateComponent(log)) {
                // The date format only contains time components, so perform truncate to avoid duplicates
                truncate(log, writer);

                collector.addMessage(new Status(IStatus.INFO, IndexPlugin.PLUGIN_ID,
                        Messages.LuceneIndexService_info_autoTruncate_noDateComponent));
            }

            // Perform synchronize
            log.synchronize(collector, monitor);
            return new SynchronizationResult(monitor.isCanceled(), collector.getTotalCollected(),
                    System.currentTimeMillis() - startTime, collector.getMessages());
        }
    };
    return runnable.runWithIndexWriter(log, getAnalyzer(), getMatchVersion());
}

From source file:co.com.soinsoftware.hotelero.view.JFRoomService.java

private void jcbRoomActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jcbRoomActionPerformed
    final Invoice invoice = this.getInvoiceSelected();
    this.refreshService();
    if (invoice != null) {
        this.setEnabledNewServiceFields(true);
        final User user = invoice.getUser();
        this.jtfIdentification.setText(String.valueOf(user.getIdentification()));
        this.jtfName.setText(user.getName());
        this.jdcInitialDate.setMinSelectableDate(invoice.getInitialDate());
        final Date finalDate = invoice.getFinalDate();
        final Date currentDate = new Date();
        if (!DateUtils.isSameDay(currentDate, finalDate) && currentDate.after(finalDate)) {
            this.jdcInitialDate.setMaxSelectableDate(currentDate);
        } else {/* ww  w .  j  av a2  s.c  o m*/
            this.jdcInitialDate.setMaxSelectableDate(invoice.getFinalDate());
        }
    } else {
        this.setEnabledNewServiceFields(false);
        this.jtfIdentification.setText("");
        this.jtfName.setText("");
    }
}

From source file:jp.co.ctc_g.jfw.core.util.Dates.java

/**
 * 2?1???????????.// w  w w .  j a v  a2 s .c o  m
 * @param fromDate1 
 * @param toDate1 
 * @param fromDate2 2
 * @param toDate2 2
 * @return true:?????false:??????
 */
public static boolean isDateInclude(Date fromDate1, Date toDate1, Date fromDate2, Date toDate2) {

    fromDate1 = truncate(fromDate1, Dates.DAY);
    toDate1 = truncate(toDate1, Dates.DAY);
    fromDate2 = truncate(fromDate2, Dates.DAY);
    toDate2 = truncate(toDate2, Dates.DAY);
    if ((fromDate1.before(fromDate2) || fromDate1.equals(fromDate2)) && // 11??2???
            (toDate1.after(fromDate2) || toDate1.equals(fromDate2))
            && (fromDate1.before(toDate2) || fromDate1.equals(toDate2)) && // ???11??2???
            (toDate1.after(toDate2) || toDate1.equals(toDate2)))
        return true;
    return false;
}

From source file:dk.dma.ais.utils.filter.AisFilter.java

@Override
public void accept(AisPacket packet) {
    if (out == null) {
        // Open new output stream
        out = getNextOutputStram();//from   www .j  a v  a  2  s .co m
    }

    end = System.currentTimeMillis();
    if (start == 0) {
        start = end;
    }

    for (IPacketFilter filter : filters) {
        if (filter.rejectedByFilter(packet)) {
            return;
        }
    }

    Integer baseMMSI = -1;
    String country = "";
    String region = "";

    Vdm vdm = packet.getVdm();
    if (vdm == null) {
        return;
    }

    // Get source tag properties
    IProprietarySourceTag sourceTag = vdm.getSourceTag();
    if (sourceTag != null) {
        baseMMSI = sourceTag.getBaseMmsi();
        if (sourceTag.getCountry() != null) {
            country = sourceTag.getCountry().getTwoLetter();
        }
        if (sourceTag.getRegion() != null) {
            region = sourceTag.getRegion();
        }
    }
    if (region.equals("")) {
        region = "0";
    }

    // Maybe check for start date
    Date timestamp = vdm.getTimestamp();
    if (filter.getStartDate() != null && timestamp != null) {
        if (timestamp.before(filter.getStartDate())) {
            return;
        }
    }

    // Maybe check for end date
    if (filter.getEndDate() != null && timestamp != null) {
        if (timestamp.after(filter.getEndDate())) {
            System.exit(0);
        }
    }

    // Maybe check for base station MMSI
    if (filter.getBaseStations().size() > 0) {
        if (!filter.getBaseStations().contains(baseMMSI)) {
            return;
        }
    }

    // Maybe check for country
    if (filter.getCountries().size() > 0) {
        if (!filter.getCountries().contains(country)) {
            return;
        }
    }

    // Maybe check for region
    if (filter.getRegions().size() > 0) {
        if (!filter.getRegions().contains(region)) {
            return;
        }
    }

    if (stop) {
        return;
    }

    // Count message
    msgCount++;

    // Print tag line packet
    out.print(packet.getStringMessage() + "\r\n");

    // Count bytes
    bytes += packet.getStringMessage().length() + 2;
    currentFileBytes += packet.getStringMessage().length() + 2;

    // Maybe print parsed
    if (dumpParsed) {
        if (timestamp != null) {
            out.println("+ timetamp " + timestampFormat.format(timestamp));
        }
        if (vdm.getTags() != null) {
            for (IProprietaryTag tag : vdm.getTags()) {
                out.println("+ " + tag.toString());
            }
        }
        AisMessage aisMessage = packet.tryGetAisMessage();
        if (aisMessage != null) {
            out.println("+ " + aisMessage.toString());
        } else {
            out.println("+ AIS message could not be parsed");
        }

        // Check for binary message
        if (aisMessage instanceof AisBinaryMessage) {
            AisBinaryMessage binaryMessage = (AisBinaryMessage) aisMessage;
            try {
                AisApplicationMessage appMessage = binaryMessage.getApplicationMessage();
                out.println(appMessage);
            } catch (SixbitException e) {
            }
        }
        out.println("---------------------------");
    }

    // Maybe time for new outfile
    if (splitSize != null && currentFileBytes >= splitSize) {
        out.close();
        out = null;
        currentFileBytes = 0;
    }

}

From source file:com.collabnet.ccf.pi.sfee.v44.SFEEAppHandler.java

private void addComments(List<ArtifactSoapDO> artifactHistory, ArtifactSoapDO artifact, Date lastModifiedDate,
        String connectorUser, String resyncUser) {
    try {//from ww  w.j a va 2 s.c  o  m
        CommentSoapList commentList = mSfSoap.getCommentList(mSessionId, artifact.getId());
        CommentSoapRow[] comments = commentList.getDataRows();
        if (comments != null) {
            for (CommentSoapRow comment : comments) {
                String createdBy = comment.getCreatedBy();
                Date createdDate = comment.getDateCreated();
                if (createdBy.equals(connectorUser) || createdBy.equals(resyncUser)) {
                    continue;
                }
                if (lastModifiedDate.after(createdDate) || lastModifiedDate.equals(createdDate)) {
                    continue;
                }
                String description = comment.getDescription();
                description = "\nOriginal commenter: " + createdBy + "\n" + description;
                boolean commentSet = false;
                for (ArtifactSoapDO artifactDO : artifactHistory) {
                    // TODO If nothing is matching what will happen?
                    // if(artifactDO.getLastModifiedDate().after(createdDate)
                    // ||
                    // artifactDO.getLastModifiedDate().equals(createdDate)){
                    // TODO If more than one comment is added, How this will
                    // behave?
                    this.addComment(ArtifactMetaData.SFEEFields.commentText.getFieldName(), artifactDO,
                            description);
                    commentSet = true;
                    break;
                    // }
                }
                if (!commentSet) {
                    log.error("Comment " + description + " Could not be set " + createdDate);
                }
            }
        }
    } catch (RemoteException e) {
        log.error("Could not get comments list for artifact " + artifact.getId() + ": " + e.getMessage());
    }
}

From source file:com.cws.esolutions.security.processors.impl.AccountResetProcessorImpl.java

/**
 * @see com.cws.esolutions.security.processors.interfaces.IAccountResetProcessor#verifyResetRequest(com.cws.esolutions.security.processors.dto.AccountResetRequest)
 *//*  w w w  .java2 s  . com*/
public AccountResetResponse verifyResetRequest(final AccountResetRequest request) throws AccountResetException {
    final String methodName = IAccountResetProcessor.CNAME
            + "#verifyResetRequest(final AccountResetRequest request) throws AccountResetException";

    if (DEBUG) {
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("AccountResetRequest: {}", request);
    }

    AccountResetResponse response = new AccountResetResponse();

    final Calendar cal = Calendar.getInstance();
    final RequestHostInfo reqInfo = request.getHostInfo();

    if (DEBUG) {
        DEBUGGER.debug("Calendar: {}", cal);
        DEBUGGER.debug("RequestHostInfo: {}", reqInfo);
    }

    try {
        cal.add(Calendar.MINUTE, secConfig.getResetTimeout());

        if (DEBUG) {
            DEBUGGER.debug("Reset expiry: {}", cal.getTimeInMillis());
        }

        // the request id should be in here, so lets make sure it exists
        List<Object> resetData = userSec.getResetData(request.getResetRequestId());

        final String commonName = (String) resetData.get(0);
        final Date resetTimestamp = (Date) resetData.get(1);

        if (DEBUG) {
            DEBUGGER.debug("String: {}", commonName);
            DEBUGGER.debug("Date: {}", resetTimestamp);
        }

        // make sure the timestamp is appropriate
        if (resetTimestamp.after(cal.getTime())) {
            response.setRequestStatus(SecurityRequestStatus.FAILURE);
        }

        // good, now we have something we can look for
        List<Object> userList = userManager.loadUserAccount(commonName);

        if (DEBUG) {
            DEBUGGER.debug("userList: {}", userList);
        }

        // we expect back only one
        if ((userList == null) || (userList.size() == 0)) {
            throw new AccountResetException("Unable to load user account information. Cannot continue.");
        }

        UserAccount userAccount = new UserAccount();
        userAccount.setStatus(LoginStatus.RESET);
        userAccount.setGuid((String) userList.get(0));
        userAccount.setUsername((String) userList.get(1));
        userAccount.setSurname((String) userList.get(5));
        userAccount.setGivenName((String) userList.get(6));
        userAccount.setDisplayName((String) userList.get(7));
        userAccount.setEmailAddr((String) userList.get(8));

        if (DEBUG) {
            DEBUGGER.debug("UserAccount: {}", userAccount);
        }

        // remove the reset request
        boolean isRemoved = userSec.removeResetData(userAccount.getGuid(), request.getResetRequestId());

        if (DEBUG) {
            DEBUGGER.debug("isRemoved: {}", isRemoved);
        }

        if (!(isRemoved)) {
            ERROR_RECORDER.error("Failed to remove provided reset request from datastore");
        }

        response.setRequestStatus(SecurityRequestStatus.SUCCESS);
        response.setUserAccount(userAccount);

        if (DEBUG) {
            DEBUGGER.debug("AccountResetResponse: {}", response);
        }
    } catch (SecurityServiceException ssx) {
        ERROR_RECORDER.error(ssx.getMessage(), ssx);

        throw new AccountResetException(ssx.getMessage(), ssx);
    } catch (SQLException sqx) {
        ERROR_RECORDER.error(sqx.getMessage(), sqx);

        throw new AccountResetException(sqx.getMessage(), sqx);
    }

    return response;
}

From source file:org.openmrs.module.pharmacyapi.api.prescription.util.AbstractPrescriptionItemGenerator.java

public boolean isOrderExpired(final PrescriptionItem item, final Date creationDate) {

    final Double drugToPickUp = item.getDrugToPickUp();

    final Date nextPickUpDate = this.getNextPickUpDate(item.getDrugOrder());

    final Calendar calendar = Calendar.getInstance();
    calendar.setTime(nextPickUpDate);/*from w  w  w  .  ja  v  a  2s  .  co m*/
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    calendar.add(Calendar.DAY_OF_MONTH, drugToPickUp.intValue());

    while ((calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
            || (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)) {
        calendar.add(Calendar.DAY_OF_MONTH, -1);
    }

    return creationDate.after(calendar.getTime());
}