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:net.di2e.ecdr.querylanguage.basic.CDRKeywordQueryLanguage.java

protected TemporalCriteria createTemporalCriteria(String start, String end, String type,
        StringBuilder humanReadableQuery, String defaultDateType) throws UnsupportedQueryException {
    TemporalCriteria temporalCriteria = null;

    if (StringUtils.isNotBlank(start) || StringUtils.isNotBlank(end)) {
        Date startDate = SearchUtils.parseDate(start);
        Date endDate = SearchUtils.parseDate(end);
        if (startDate != null && endDate != null) {
            if (startDate.after(endDate)) {
                throw new UnsupportedQueryException(
                        "Start date value [" + startDate + "] cannot be after endDate [" + endDate + "]");
            }/*from  ww w. j a  va 2  s. com*/
        }
        String dateType = null;
        LOGGER.debug("Getting date type name for type [{}]", type);
        if (StringUtils.isNotBlank(type)) {
            if (dateTypeMap.containsKey(type)) {
                dateType = dateTypeMap.getMappedValue(type);

                LOGGER.debug(
                        "Date type value received in map for request value [{}], setting internal query value to [{}]",
                        type, dateType);
            } else {
                String message = "Date type value not found in map for type [" + type
                        + "], defaulting internal query value to [" + dateType + "]";
                LOGGER.warn(message);
                throw new UnsupportedQueryException(message);
            }
        } else {
            dateType = dateTypeMap.getMappedValue(defaultDateType);
            LOGGER.debug(
                    "Date type value was not specified in request, defaulting internal query value to [{}]",
                    dateType);
        }
        temporalCriteria = new TemporalCriteria(startDate, endDate, dateType);
    }
    return temporalCriteria;

}

From source file:edu.stanford.muse.util.EmailUtils.java

public static Pair<Date, Date> getFirstLast(Collection<? extends DatedDocument> allDocs,
        boolean ignoreInvalidDates) {
    // compute the begin and end date of the corpus
    Date first = null;/*  w ww . ja  v  a 2 s  .co m*/
    Date last = null;

    if (allDocs == null)
        return null;

    for (DatedDocument ed : allDocs) {
        Date d = ed.date;
        if (d == null) {
            // drop this $ed$
            EmailUtils.log.warn("Warning: null date on email: " + ed.getHeader());
            continue;
        }

        // ignore invalid date if asked
        if (ignoreInvalidDates)
            if (EmailFetcherThread.INVALID_DATE.equals(d))
                continue;

        if (first == null || d.before(first))
            first = d;
        if (last == null || d.after(last))
            last = d;
    }

    return new Pair<Date, Date>(first, last);
}

From source file:ru.apertum.qsystem.reports.formirovators.ResponsesDateReport.java

@Override
public String validate(String driverClassName, String url, String username, String password,
        HttpRequest request, HashMap<String, String> params) {
    //   ?  /*from   ww  w .j  av  a 2  s  .  c  o m*/
    QLog.l().logger().trace("?  \"" + params.toString() + "\".");
    if (params.size() == 2) {
        Date sd;
        Date fd;
        Date fd1;
        try {
            sd = Uses.format_dd_MM_yyyy.parse(params.get("sd"));
            fd = Uses.format_dd_MM_yyyy.parse(params.get("ed"));
            fd1 = DateUtils.addDays(Uses.format_dd_MM_yyyy.parse(params.get("ed")), 1);
        } catch (ParseException ex) {
            return "<br>  ! ? ?   (..).";
        }
        if (!sd.after(fd)) {
            paramMap.put("sd", sd);
            paramMap.put("ed", fd);
            paramMap.put("ed1", fd1);
        } else {
            return "<br>  !     ?.";
        }

    } else {
        return "<br>  !";
    }
    return null;// ? 
}

From source file:com.activecq.samples.replication.impl.ReverseReplicatorImpl.java

private boolean shouldReplicate(final Resource resource, Event event) {
    if (StringUtils.equals(event.getTopic(), SlingConstants.TOPIC_RESOURCE_CHANGED)) {
        ValueMap properties = resource.adaptTo(ValueMap.class);

        final Date lastModified = properties.get(JcrConstants.JCR_LASTMODIFIED, Date.class);
        final Date lastReplicated = properties.get("cq:lastReplicated", Date.class);

        if (lastReplicated == null) {
            return true;
        }//from   w  w  w  .jav  a  2s . com
        if (lastModified == null) {
            setLastModified(resource);
        }

        log.debug("LM " + lastModified.getTime() + " >= LR " + lastReplicated.getTime() + " => "
                + lastModified.after(lastReplicated));

        // Last Modified must be >= Last Replicated
        return lastModified.after(lastReplicated);
    } else {
        return true;
    }
}

From source file:com.jaspersoft.jasperserver.war.themes.ThemeResolverServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    // Check if we can find a resource in the current theme
    //String resPath = req.getRequestURI().substring((req.getContextPath() + req.getServletPath()).length());
    String resPath = req.getRequestURI().substring(req.getContextPath().length() + 1);
    ThemeResource themeResource = themeCache.getThemeResource(resPath);
    if (themeResource == null) {
        resp.sendError(404);/*from  w  ww .  j a v  a2  s.c  om*/
        return;
    }

    // Set contentType
    String filename = resPath;
    if (filename.indexOf("/") >= 0) {
        filename = filename.substring(filename.lastIndexOf("/") + 1);
    }
    String contentType = servletContext.getMimeType(filename);
    if (contentType == null) {
        log.error("Cannot detect a response content type for the file : " + filename);
        resp.sendError(404);
        return;
    }
    resp.setContentType(contentType);

    // Get Last Modified date
    Date lastModified = themeResource.getLastModified();
    // Get rid of ms
    lastModified.setTime(lastModified.getTime() / 1000 * 1000);

    // Set cache controlling HTTP Response Headers
    DateFormat df = getFormat(req.getLocale());
    resp.setHeader("Cache-Control", "max-age=" + expiresInSecs + ", public");
    resp.setHeader("Pragma", "");
    resp.setHeader("Last-Modified", df.format(lastModified));
    resp.setHeader("Expires", df.format(new Date(new Date().getTime() + expiresInSecs * 1000)));

    // Send 304 if resource has not been modified since last time requested
    String ifModSince = req.getHeader("If-Modified-Since");
    try {
        Date modDate = df.parse(ifModSince);
        if (!lastModified.after(modDate)) {
            resp.setStatus(304);
            return;
        }
    } catch (Exception e) {
    }

    // Send the full content
    resp.setContentLength(themeResource.getContent().length);
    ServletOutputStream os = resp.getOutputStream();
    os.write(themeResource.getContent());
    os.flush();
    os.close();
}

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

/**
 * 2???????????????./*from   w  w  w . ja  v  a  2  s  .  c om*/
 * @param fromDate1 
 * @param toDate1 
 * @param fromDate2 2
 * @param toDate2 2
 * @return true:??????false:???????
 */
public static boolean isDateOverlap(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.equals(fromDate2) || toDate1.equals(toDate2) || // ????????
            fromDate1.equals(toDate2) || toDate1.equals(fromDate2))
            || (fromDate1.before(fromDate2) && toDate1.after(fromDate2)) || // ?????????
            (fromDate2.before(fromDate1) && toDate2.after(fromDate1))) // ?????????
        return true;
    return false;
}

From source file:com.virtusa.akura.reporting.controller.PerDayStaffCategoryWiseAttendanceController.java

/**
 * get present staff list with half day leave reason if any.
 *
 * @param presentStaffList - present staff list
 * @param dateConsider - date of the report .
 * @return map of staff//from w w  w  .  j  ava2  s . c o m
 * @throws AkuraAppException throw exception if occur.
 */
private Map<Staff, String> getPresentStaffListWithLeaveReason(List<Staff> presentStaffList, Date dateConsider)
        throws AkuraAppException {

    // create an present map for staffs with half day leave reason.

    Map<Staff, String> presentMap = new LinkedHashMap<Staff, String>();
    // Map<Staff, String> presentMap = new TreeMap<Staff, String>();
    Date attDate = dateConsider;

    if (!presentStaffList.isEmpty()) {

        for (Staff staff : presentStaffList) {
            String leaveDayType = null;
            List<StaffLeave> staffLeaveList = staffService.getStaffLeaveListByDatePeriodAndStaffId(attDate,
                    attDate, staff.getStaffId());

            if (!staffLeaveList.isEmpty()) {

                for (StaffLeave sl : staffLeaveList) {

                    Date getFromDate = DateUtil.getParseDate(sl.getFromDate().toString());
                    Date getToDate = DateUtil.getParseDate(sl.getToDate().toString());

                    if (getFromDate.before(attDate) && getToDate.after(attDate)) {

                        if (sl.getStaffLeaveStatusId().intValue() == 1) {
                            leaveDayType = sl.getDateType();
                        }

                    } else if (getFromDate.equals(attDate) || getToDate.equals(attDate)) {
                        if (sl.getStaffLeaveStatusId().intValue() == 1) {
                            leaveDayType = sl.getDateType();
                        }
                    }
                }
            }

            presentMap.put(staff, leaveDayType);

        }

    }
    return presentMap;

}

From source file:com.xmobileapp.rockplayer.LastFmEventImporter.java

/********************************************
 * //  w ww .  java2  s .c o m
 * dateAfter
 *    method for comparing string dates
 *  date format Sun, 06 Mar 2008
 ********************************************/
public boolean dateAfter(String varDateString, String fixedDateString) {
    try {
        DateFormat dateFormatter = new SimpleDateFormat("E, dd MMM yyyy");
        //Log.i("DATE_", varDateString+" "+fixedDateString);
        Date varDate = dateFormatter.parse(varDateString);
        Date fixedDate = dateFormatter.parse(fixedDateString);
        if (varDate.after(fixedDate)) {
            return true;
        } else {
            return false;
        }
        //Log.i("DATE", varDate.toString());
        //Log.i("DATE", fixedDate.toString());
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:controller.CommercialController.java

@RequestMapping(value = "regub/commercial/contrats/annulercontratcom", method = RequestMethod.POST)
public String annulercontratAction(HttpServletRequest request, HttpSession session, Model model)
        throws ParseException {
    //ClientConnecte cli = new ClientConnecte((Client) session.getAttribute("UserConnected"));
    //session.removeAttribute("UserConnected");
    int idContrat = Integer.parseInt(request.getParameter("idvideo"));
    DateFormat dateformat = new SimpleDateFormat("dd-MM-yyyy");

    Video vid = VidBDD.modifcontrat(idContrat);

    String datedebut = ConvertToDate(vid.getDateDebut());
    Date ddebut = dateformat.parse(datedebut);
    //System.out.println(""+datedebut);
    //System.out.println("Con De type Date:"+ddebut);

    Date currentDate = new Date();
    String datecourante = dateformat.format(currentDate);
    Date dcourante = dateformat.parse(datecourante);
    //System.out.println(""+datecourante);
    //System.out.println("Cu De type Date:"+dcourante);

    //Raccourci la date de validation du contrat  la date courante
    if (dcourante.after(ddebut) || dcourante.equals(ddebut)) {
        //System.out.println("Date courant sup ou egale  celle du cntrat");
        vid.setDateFin(ConvertToSqlDate(datecourante));
        VidBDD.updComContrat(vid, "annuler");
    } else {/*from   w  ww.j a va  2  s . co  m*/
        //supprime le contrat si il n'est pas commenc
        //System.out.println("Date courant inf  celle du cntrat");
        VidBDD.deleteComContrat(idContrat);
    }

    //return listClientAction(request, session, model);
    //return "redirect:/regub/commercial";
    return "redirect:/regub/commercial/contrats/" + vid.getClient().getIdClient();
}

From source file:com.appeligo.alerts.KeywordAlertChecker.java

public void sendMessages(KeywordAlert keywordAlert, String fragments, Document doc, String messagePrefix) {

    User user = keywordAlert.getUser();/*from ww w. j  a  v a2 s .  co  m*/
    if (user == null) {
        return;
    }
    String programId = doc.get("programID");
    String programTitle = doc.get("programTitle");

    if (log.isDebugEnabled())
        log.debug("keywordAlert: " + keywordAlert.getUserQuery() + ", sending message to "
                + (user == null ? null : user.getUsername()));

    try {
        // Use the user's lineup to determine the start time of this program which might air at different times for diff timezones
        String startTimeString = doc.get("lineup-" + user.getLineupId() + "-startTime");
        if (startTimeString == null) {
            // This user doesn't have the channel or program that our local feed has
            if (log.isDebugEnabled()) {
                String station = doc.get("lineup-" + liveLineup + "-stationName");
                log.debug("No startTime for station " + station + ", program " + programTitle + ", lineup="
                        + user.getLineupId() + ", start time from live lineup="
                        + doc.get("lineup-" + liveLineup + "-startTime"));
            }
            return;
        }
        Date startTime = DateTools.stringToDate(startTimeString);
        Date endTime = DateTools.stringToDate(doc.get("lineup-" + user.getLineupId() + "-endTime"));
        long durationMinutes = (endTime.getTime() - startTime.getTime()) / (60 * 1000);

        Date now = new Date();
        boolean future = endTime.after(now);
        boolean onAirNow = startTime.before(now) && future;
        boolean past = !(future || onAirNow);

        ProgramType programType = ProgramType.fromProgramID(programId);

        boolean uniqueProgram = false;
        if (programType == ProgramType.EPISODE || programType == ProgramType.SPORTS
                || programType == ProgramType.MOVIE) {
            uniqueProgram = true;
        }

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

        boolean includeDate;
        DateFormat format;
        if (Math.abs(startTime.getTime() - System.currentTimeMillis()) < 12 * 60 * 60 * 1000) {
            format = DateFormat.getTimeInstance(DateFormat.SHORT);
            includeDate = false;
        } else {
            format = new SimpleDateFormat("EEEE, MMMM d 'at' h:mm a");
            includeDate = true;
        }
        format.setTimeZone(user.getTimeZone());
        context.put("startTime", format.format(startTime));
        if (includeDate) {
            format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
            format.setTimeZone(user.getTimeZone());
        }
        context.put("shortStartTime", format.format(startTime));

        context.put("durationMinutes", Long.toString(durationMinutes));
        // Use the SDTW-C lineup because this is how we know the right channel (station callsign) where we caught the
        // keyword.
        String stationName = doc.get("lineup-" + liveLineup + "-stationName");
        context.put("stationName", stationName);
        boolean sameStation = false;
        if (stationName.equals(doc.get("lineup-" + user.getLineupId() + "-stationName"))) {
            sameStation = true;
        }
        context.put("stationCallSign", doc.get("lineup-" + liveLineup + "-stationCallSign"));

        if (sameStation) {
            if (onAirNow) {
                context.put("timeChannelIntro", "We have been monitoring <b>" + stationName
                        + "</b>, and your topic was recently mentioned on the following program:");
            } else if (future) {
                if (uniqueProgram) {
                    context.put("timeChannelIntro", "We are monitoring <b>" + stationName
                            + "</b>, and your topic will be mentioned on the following program:");
                } else {
                    context.put("timeChannelIntro",
                            "We are monitoring <b>" + stationName + "</b>, and your topic was mentioned on <b>"
                                    + programTitle + "</b>. It may be mentioned when this program airs again:");
                }
            } else {
                context.put("timeChannelIntro", "We have been monitoring <b>" + stationName
                        + "</b>, and your topic was mentioned on a program that aired in your area in the past. "
                        + "You may have an opportunity to see this program in the future:");
            }
        } else {
            if (onAirNow) {
                context.put("timeChannelIntro", "We have been monitoring <b>" + programTitle
                        + "</b>, and your topic was recently mentioned:");
            } else if (future) {
                if (uniqueProgram) {
                    context.put("timeChannelIntro", "We have been monitoring <b>" + programTitle
                            + "</b>, and your topic was mentioned.  You may have an opportunity to catch this program when it airs again according to the following schedule:");
                } else {
                    context.put("timeChannelIntro", "We have been monitoring <b>" + programTitle
                            + "</b>, and your topic was mentioned.  This program will air again as follows, but the topics may or may not be the same:");
                }
            } else {
                context.put("timeChannelIntro", "We have been monitoring <b>" + programTitle
                        + "</b>, and your topic was mentioned.  However, this program aired in your area in the past. "
                        + "You may have an opportunity to see this program in the future:");
            }
        }
        if (onAirNow) {
            context.put("startsAt", "Started at");
        } else if (future) {
            if (includeDate) {
                context.put("startsAt", "Starts on");
            } else {
                context.put("startsAt", "Starts at");
            }
        } else {
            if (includeDate) {
                context.put("startsAt", "Last aired on");
            } else {
                context.put("startsAt", "Previously aired at");
            }
        }
        context.put("lcStartsAt", context.get("startsAt").toLowerCase());

        String webPath = doc.get("webPath");
        if (webPath == null) {
            webPath = DefaultEpg.getInstance().getProgram(programId).getWebPath();
        }
        if (webPath.charAt(0) == '/') {
            webPath = webPath.substring(1);
        }
        String reducedTitle40 = doc.get("reducedTitle40");
        if (reducedTitle40 == null) {
            reducedTitle40 = DefaultEpg.getInstance().getProgram(programId).getReducedTitle40();
        }
        String programLabel = doc.get("programLabel");
        if (programLabel == null) {
            programLabel = DefaultEpg.getInstance().getProgram(programId).getLabel();
        }
        context.put("programId", programId);
        context.put("webPath", webPath);
        context.put("programLabel", programLabel);
        context.put("reducedTitle40", reducedTitle40);
        if (doc.get("description").trim().length() > 0) {
            context.put("description", "Description: " + doc.get("description") + "<br/>");
        } else {
            context.put("description", "");
        }
        if (fragments == null || fragments.trim().length() == 0) {
            context.put("fragments", "");
        } else {
            context.put("fragments", "Relevant Dialogue: <i>" + fragments + "</i><br/>");
        }
        context.put("query", keywordAlert.getUserQuery());
        context.put("keywordAlertId", Long.toString(keywordAlert.getId()));
        String greeting = user.getUsername();
        context.put("username", greeting);
        String firstName = user.getFirstName();
        if (firstName != null && firstName.trim().length() > 0) {
            greeting = firstName;
        }
        context.put("greeting", greeting);

        format = DateFormat.getTimeInstance(DateFormat.SHORT);
        format.setTimeZone(user.getTimeZone());
        context.put("now", format.format(new Date()));

        ScheduledProgram futureProgram = DefaultEpg.getInstance().getNextShowing(user.getLineupId(), programId,
                false, false);
        if (uniqueProgram) {
            String typeString = null;
            if (programType == ProgramType.EPISODE) {
                typeString = "episode";
            } else if (programType == ProgramType.SPORTS) {
                typeString = "game";
            } else {
                typeString = "movie";
            }
            if (futureProgram != null) {
                String timePreposition = null;
                if ((futureProgram.getStartTime().getTime() - System.currentTimeMillis()) < 12 * 60 * 60
                        * 1000) {
                    timePreposition = "at ";
                    format = DateFormat.getTimeInstance(DateFormat.SHORT);
                } else {
                    timePreposition = "on ";
                    format = new SimpleDateFormat("EEEE, MMMM d 'at' h:mm a");
                }
                format.setTimeZone(user.getTimeZone());
                context.put("rerunInfo", "You can still catch this " + typeString
                        + " in its entirety!  It's scheduled to replay " + timePreposition
                        + format.format(futureProgram.getStartTime()) + " on "
                        + futureProgram.getNetwork().getStationName() + ". Do you want to <a href=\"" + url
                        + webPath + "#addreminder\">set a reminder</a> to be notified the next time this "
                        + typeString + " airs?");
            } else {
                if (programType == ProgramType.SPORTS) {
                    context.put("rerunInfo", "");
                } else {
                    if (onAirNow) {
                        context.put("rerunInfo",
                                "If it's too late to flip on the program now, you can <a href=\"" + url
                                        + webPath
                                        + "#addreminder\">set a reminder</a> to be notified the next time this "
                                        + typeString + " airs.");
                    } else {
                        context.put("rerunInfo",
                                "You can <a href=\"" + url + webPath
                                        + "#addreminder\">set a reminder</a> to be notified the next time this "
                                        + typeString + " airs.");
                    }
                }
            }
        } else {
            if ((futureProgram != null) && futureProgram.isNewEpisode()) {
                context.put("rerunInfo",
                        "The next airing of this show will be new content, and is <i>not a rerun</i>,"
                                + " so these same topics may or may not be discussed."
                                + "  You may still be interested in catching future airings, and you can"
                                + " <a href=\"" + url + webPath
                                + "#addreminder\">set a Flip.TV reminder for this show</a>.");
            } else {
                context.put("rerunInfo",
                        "The broadcaster did not provide enough information to know which future airings,"
                                + " if any, are identical reruns with the same topics mentioned."
                                + "  You may still be interested in catching future airings, and you can"
                                + " <a href=\"" + url + webPath
                                + "#addreminder\">set a Flip.TV reminder for this show</a>.");
            }
        }

        if (keywordAlert.getTodaysAlertCount() == keywordAlert.getMaxAlertsPerDay()) {
            context.put("maxAlertsExceededSentence",
                    "You asked to stop receiving alerts for this topic after receiving "
                            + keywordAlert.getMaxAlertsPerDay()
                            + " alerts in a single day. That limit has been reached. You can change this setting"
                            + " at any time.  Otherwise, we will resume sending alerts"
                            + " for this topic tomorrow.");
        } else {
            context.put("maxAlertsExceededSentence", "");
        }

        if (keywordAlert.isUsingPrimaryEmailRealtime()) {
            Message message = new Message(messagePrefix + "_email", context);
            message.setUser(user);
            message.setTo(user.getPrimaryEmail());
            if (log.isDebugEnabled())
                log.debug("Sending email message to: " + user.getPrimaryEmail());
            message.insert();
        }
        if (keywordAlert.isUsingSMSRealtime() && user.getSmsEmail().trim().length() > 0) {
            Message message = new Message(messagePrefix + "_sms", context);
            message.setTo(user.getSmsEmail());
            message.setUser(user);
            message.setSms(true);
            if (log.isDebugEnabled())
                log.debug("Sending sms message to: " + user.getSmsEmail());
            message.insert();
        }
    } catch (NumberFormatException e) {
        log.error("Couldn't process lucene document for program " + programId, e);
    } catch (MessageContextException e) {
        log.error("Software bug resulted in exception with email message context or configuration", e);
    } catch (ParseException e) {
        log.error(
                "Software bug resulted in exception with document 'startTime' or 'endTime' format in lucene document for program id "
                        + programId,
                e);
    }
}