List of usage examples for java.util Date before
public boolean before(Date when)
From source file:dk.dr.radio.data.Kanal.java
/** Finder den aktuelle udsendelse p kanalen */ @Override// w w w . j av a 2 s. c o m public Udsendelse getUdsendelse() { if (udsendelser == null || udsendelser.size() == 0) return null; Date nu = new Date(App.serverCurrentTimeMillis()); // Kompenseret for forskelle mellem telefonens ur og serverens ur // Nicolai: "jeg lber listen igennem fra bunden og op, // og s finder jeg den frste der har starttid >= nuvrende tid + sluttid <= nuvrende tid." for (int n = udsendelser.size() - 1; n >= 0; n--) { Udsendelse u = udsendelser.get(n); //Log.d(n + " " + nu.after(u.startTid) + u.slutTid.before(nu) + " " + u); if (u.startTid.before(nu)) { // && nu.before(u.slutTid)) { return u; } } Log.e(new IllegalStateException("Ingen aktuel udsendelse fundet!")); Log.d("nu = " + nu + " - " + nu.getTime() + " " + DRBackendTidsformater.servertidsformat.format(nu)); for (int n = 0; n < udsendelser.size(); n++) { Udsendelse u = udsendelser.get(n); Log.d(n + " " + u.startTid.before(nu) + nu.before(u.slutTid) + " " + u + " " + DRBackendTidsformater.servertidsformat.format(u.startTid) + " - " + DRBackendTidsformater.servertidsformat.format(u.slutTid)); } if (nu.before(udsendelser.get(0).slutTid)) return udsendelser.get(0); return null; }
From source file:com.tasktop.c2c.server.scm.service.GitServiceBean.java
@Secured({ Role.Observer, Role.User }) @Override//from w ww .ja v a2 s . c o m public List<ScmSummary> getScmSummary(int numDays) { final List<ScmSummary> summary = createEmptySummaries(numDays); final Date firstDate = summary.get(0).getDate(); CommitVisitor visitor = new CommitVisitor() { @Override public void visit(RevCommit revCommit) { Date commitDate = revCommit.getAuthorIdent().getWhen(); if (commitDate.before(firstDate)) { return; } for (int i = 0; i < summary.size(); i++) { if (i == summary.size() - 1) { summary.get(i).setAmount(summary.get(i).getAmount() + 1); } else if (summary.get(i).getDate().before(commitDate) && commitDate.before(summary.get(i + 1).getDate())) { summary.get(i).setAmount(summary.get(i).getAmount() + 1); break; } } } }; visitAllCommitsAfter(firstDate, visitor); return summary; }
From source file:ddf.security.assertion.impl.SecurityAssertionImpl.java
@Override public boolean isPresentlyValid() { Date now = new Date(); if (getNotBefore() != null && now.before(getNotBefore())) { LOGGER.debug("SAML Assertion Time Bound Check Failed."); LOGGER.debug("\t Checked time of {} is before the NotBefore time of {}", now, getNotBefore()); return false; }/*from w w w. j a va2s. c o m*/ if (getNotOnOrAfter() != null && (now.equals(getNotOnOrAfter()) || now.after(getNotOnOrAfter()))) { LOGGER.debug("SAML Assertion Time Bound Check Failed."); LOGGER.debug("\t Checked time of {} is equal to or after the NotOnOrAfter time of {}", now, getNotOnOrAfter()); return false; } return true; }
From source file:com.aurel.track.report.dashboard.StatusOverTimeGraph.java
/** * Create a map of hierarchical data with TWorkItemBeans in the periods * - key: year/*w w w .jav a2 s .com*/ * - value: map * - key: period * - Set of TStateChangeBeans, one for each workItem * @param timeInterval * @return */ private static SortedMap<Integer, SortedMap<Integer, List<TWorkItemBean>>> getNewWorkItemsMap(List workItemList, int timeInterval, Date dateFrom, Date dateTo) { SortedMap<Integer, SortedMap<Integer, List<TWorkItemBean>>> yearToIntervalToWorkItemBeans = new TreeMap(); int yearValue; int intervalValue; if (workItemList != null) { Calendar calendarCreated = Calendar.getInstance(); Iterator iterator = workItemList.iterator(); int calendarInterval = getCalendarInterval(timeInterval); while (iterator.hasNext()) { TWorkItemBean workItemBean = (TWorkItemBean) iterator.next(); Date createDate = workItemBean.getCreated(); if (createDate == null) { continue; } if (dateFrom != null && dateFrom.after(createDate) || dateTo != null && dateTo.before(createDate)) { continue; } calendarCreated.setTime(workItemBean.getCreated()); yearValue = calendarCreated.get(Calendar.YEAR); intervalValue = calendarCreated.get(calendarInterval); if (Calendar.WEEK_OF_YEAR == calendarInterval) { //avoid adding the first week of the new year as the first week of the old year, //because it can be that the year is the old one but the last days of the year belong to the first week of the next year //and that would add an entry with the first week of the old year int monthValue = calendarCreated.get(Calendar.MONTH); if (monthValue >= 11 && intervalValue == 1) { yearValue = yearValue + 1; } } SortedMap<Integer, List<TWorkItemBean>> intervalToWorkItemBeans = yearToIntervalToWorkItemBeans .get(new Integer(yearValue)); if (intervalToWorkItemBeans == null) { yearToIntervalToWorkItemBeans.put(new Integer(yearValue), new TreeMap()); intervalToWorkItemBeans = yearToIntervalToWorkItemBeans.get(new Integer(yearValue)); } List<TWorkItemBean> workItemBeansForInterval = intervalToWorkItemBeans .get(new Integer(intervalValue)); if (workItemBeansForInterval == null) { intervalToWorkItemBeans.put(new Integer(intervalValue), new ArrayList()); workItemBeansForInterval = intervalToWorkItemBeans.get(new Integer(intervalValue)); } workItemBeansForInterval.add(workItemBean); } } return yearToIntervalToWorkItemBeans; }
From source file:com.vaadin.addon.jpacontainer.demo.InvoiceView.java
protected void doFilter() { Date from = (Date) filterFrom.getValue(); Date to = (Date) filterTo.getValue(); Object customerId = filterCustomer.getValue(); boolean overdue = filterOverdue.booleanValue(); if (customerId == null && from == null && to == null && !overdue) { getWindow().showNotification("Nothing to do"); return;// w w w. j av a 2 s. c om } invoiceContainer.removeAllContainerFilters(); if (customerId != null) { Customer c = customerContainer.getItem(customerId).getEntity(); invoiceContainer.addContainerFilter(new Equal("order.customer", c)); } if (overdue) { invoiceContainer.addContainerFilter(new Less("dueDate", new Date())); invoiceContainer.addContainerFilter(new IsNull("paidDate")); } if (from != null && to != null) { if (to.before(from)) { getWindow().showNotification("Please check the dates!", Notification.TYPE_WARNING_MESSAGE); return; } invoiceContainer.addContainerFilter(new Between("invoiceDate", from, to)); } else if (from != null) { invoiceContainer.addContainerFilter(new GreaterOrEqual("invoiceDate", from)); } else if (to != null) { invoiceContainer.addContainerFilter(new LessOrEqual("invoiceDate", to)); } invoiceContainer.applyFilters(); resetBtn.setEnabled(true); }
From source file:View.DialogoEstadisticas.java
private boolean combrobarIntervalo(String periodo) { if (intervalo) { String fechaI = null;// w w w .j a va 2s.co m String fechaF = null; String periodoI = null; String periodoF = null; SimpleDateFormat dt1 = new SimpleDateFormat("dd-MM-yyyy"); StringTokenizer st = new StringTokenizer(periodo, "/"); while (st.hasMoreTokens()) { fechaI = st.nextToken(); fechaF = st.nextToken(); } st = new StringTokenizer(fechaIntervaloI, "/"); periodoI = st.nextToken(); st = new StringTokenizer(fechaIntervaloF, "/"); while (st.hasMoreTokens()) { st.nextToken(); periodoF = st.nextToken(); } try { Date dI = dt1.parse(fechaI); Date dF = dt1.parse(fechaF); Date dIntevaloI = dt1.parse(periodoI); Date dIntevaloF = dt1.parse(periodoF); return (dI.after(dIntevaloI) && dF.before(dIntevaloF)) || (dI.compareTo(dIntevaloI) == 0) || (dF.compareTo(dIntevaloF) == 0); } catch (ParseException ex) { Logger.getLogger(DialogoEstadisticas.class.getName()).log(Level.SEVERE, null, ex); return false; } } else { return true; } }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoAttachments.java
private void fetchChildrenForNotesView() { LOGGER.debug("Fetching children for " + this.getName()); Document curDoc = null;//from ww w .j a v a 2 s .c om Document nextDoc = null; View curView = null; Database curDb = null; Vector<IDAVResource> resMembers = null; String notesURL = this.getInternalAddress(); curView = DominoProxy.getView(notesURL); if (curView == null) { LOGGER.error("Could not retrieve view: " + notesURL); return; } // Read the repository list to get the view try { LOGGER.debug("Openend view " + curView.getName()); // Initialize an empty vector at the right size // We might need to enlarge it if we have more attachments resMembers = new Vector<IDAVResource>(curView.getEntryCount()); curDoc = curView.getFirstDocument(); if (curDoc == null) { LOGGER.info(this.getName() + " does not (yet) contain resources"); return; } while (curDoc != null) { nextDoc = curView.getNextDocument(curDoc); // TODO: Fix this! DAVResourceDominoAttachments docRes = this.addAttachmentsFromDocument(curDoc); if (docRes != null) { resMembers.add(docRes); // Capture last modified based on the latest date of the // documents in view Date viewDate = this.getLastModified(); Date docDate = docRes.getLastModified(); if (viewDate == null || (docDate != null && viewDate.before(docDate))) { this.setLastModified(docDate); } } curDoc.recycle(); curDoc = nextDoc; } } catch (NotesException ne) { LOGGER.error(ne); } catch (Exception e) { LOGGER.error(e); } finally { try { if (curDoc != null) { curDoc.recycle(); } if (nextDoc != null) { nextDoc.recycle(); } if (curView != null) { curView.recycle(); } if (curDb != null) { curDb.recycle(); } } catch (Exception e) { LOGGER.error(e); } LOGGER.debug("Completed reading file resources from Domino view"); } // Now save back the members to the main object this.setMembers(resMembers); }
From source file:com.appeligo.alerts.KeywordAlertChecker.java
public void sendMessages(KeywordAlert keywordAlert, String fragments, Document doc, String messagePrefix) { User user = keywordAlert.getUser();// w w w. j a va2 s . c om 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); } }
From source file:com.manydesigns.portofino.pageactions.crud.CrudAction4ItsProject.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public void processExpiredOldDelete(Object row) { Map rowMap = (HashMap) row; Date t_time = (Date) rowMap.get("c_warranty_end"); if (null != t_time) { rowMap.put("c_is_expired", t_time.before(DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH))); }//from w w w . j av a 2 s .c om }