List of usage examples for java.util Date before
public boolean before(Date when)
From source file:de.codesourcery.eve.skills.ui.components.impl.PriceHistoryComponent.java
protected void rememberDate(Date d) { if (this.earliestDate == null || d.before(this.earliestDate)) { earliestDate = d;// www . j ava2 s . c om } if (latestDate == null || d.after(latestDate)) { latestDate = d; } }
From source file:com.devnexus.ting.web.controller.RegisterController.java
@RequestMapping(value = "/s/register-overview", method = RequestMethod.GET) public String getRegistrationOverview(Model model) { EventSignup signUp = businessService.getEventSignup(); prepareHeader(signUp.getEvent(), model); List<TicketGroup> currentTickets = signUp.getGroups().stream().filter((TicketGroup group) -> { Date now = new Date(); return (now.after(group.getOpenDate()) && now.before(group.getCloseDate())); }).collect(Collectors.toList()); List<TicketGroup> invididualTicketGroups = currentTickets.stream().filter((TicketGroup group) -> { return group.getMinPurchase() == 1; }).collect(Collectors.toList()); List<TicketGroup> groupTicketGroups = currentTickets.stream().filter((TicketGroup group) -> { return group.getMinPurchase() > 1; }).collect(Collectors.toList()); model.addAttribute("invididualTicketGroups", invididualTicketGroups); model.addAttribute("groupTicketGroups", groupTicketGroups); return "register-overview"; }
From source file:org.jasig.schedassist.web.VisibleScheduleTag.java
@Override public int doStartTagInternal() { final ServletContext servletContext = pageContext.getServletContext(); final Date scheduleStart = visibleSchedule.getScheduleStart(); if (null == scheduleStart) { // the visibleSchedule is empty, short circuit try {/*from w ww.j a va 2 s.c o m*/ StringBuilder noappointments = new StringBuilder(); noappointments.append("<span class=\"none-available\">"); noappointments.append(getMessageSource().getMessage("no.available.appointments", null, null)); noappointments.append("</span>"); pageContext.getOut().write(noappointments.toString()); } catch (IOException e) { LOG.error("IOException occurred in doStartTag", e); } // SKIP_BODY means don't print any content from body of tag return SKIP_BODY; } LOG.debug("scheduleStart: " + scheduleStart); SortedMap<Date, List<AvailableBlock>> dailySchedules = new TreeMap<Date, List<AvailableBlock>>(); Date index = DateUtils.truncate(scheduleStart, java.util.Calendar.DATE); Date scheduleEnd = visibleSchedule.getScheduleEnd(); while (index.before(scheduleEnd)) { dailySchedules.put(index, new ArrayList<AvailableBlock>()); index = DateUtils.addDays(index, 1); } final Date lastMapKey = dailySchedules.lastKey(); LOG.debug("visibleSchedule spans " + dailySchedules.keySet().size() + " days"); try { SortedMap<AvailableBlock, AvailableStatus> scheduleBlockMap = visibleSchedule.getBlockMap(); int numberOfEventsToDisplay = 0; for (AvailableBlock block : scheduleBlockMap.keySet()) { Date eventStartDate = block.getStartTime(); LOG.debug("event start date: " + eventStartDate); Date mapKey = DateUtils.truncate(eventStartDate, java.util.Calendar.DATE); if (CommonDateOperations.equalsOrAfter(eventStartDate, scheduleStart) && dailySchedules.containsKey(mapKey)) { dailySchedules.get(mapKey).add(block); numberOfEventsToDisplay++; } } LOG.debug("number of events to display: " + numberOfEventsToDisplay); if (numberOfEventsToDisplay == 0) { // no available times in this range! StringBuilder noappointments = new StringBuilder(); noappointments.append("<span class=\"none-available\">"); noappointments.append(getMessageSource().getMessage("no.available.appointments", null, null)); noappointments.append("</span>"); pageContext.getOut().write(noappointments.toString()); } else { int weekNumber = 1; Date currentWeekStart = DateUtils.truncate(scheduleStart, java.util.Calendar.DATE); Date currentWeekFinish = DateUtils.addDays(currentWeekStart, CommonDateOperations.numberOfDaysUntilSunday(currentWeekStart)); currentWeekFinish = DateUtils.addMinutes(currentWeekFinish, -1); boolean renderAnotherWeek = true; while (renderAnotherWeek) { if (LOG.isDebugEnabled()) { LOG.debug("will render another week using currentWeekStart " + currentWeekStart + " and currentWeekFinish " + currentWeekFinish); } SortedMap<Date, List<AvailableBlock>> subMap = dailySchedules.subMap(currentWeekStart, currentWeekFinish); renderWeek(servletContext, pageContext.getOut(), weekNumber++, subMap, scheduleBlockMap); currentWeekStart = DateUtils.addMinutes(currentWeekFinish, 1); currentWeekFinish = DateUtils.addDays(currentWeekStart, 7); currentWeekFinish = DateUtils.addMinutes(currentWeekFinish, -1); if (LOG.isDebugEnabled()) { LOG.debug("recalculated currentWeekStart " + currentWeekStart + ", currentWeekFinish " + currentWeekFinish); } if (currentWeekStart.after(lastMapKey)) { renderAnotherWeek = false; LOG.debug("will not render another week"); } } } } catch (IOException e) { LOG.error("IOException occurred in doStartTag", e); } // SKIP_BODY means don't print any content from body of tag return SKIP_BODY; }
From source file:com.likya.myra.jef.controller.BaseSchedulerController.java
protected boolean hasTimeCome(AbstractJobType abstractJobType) { Date scheduledTime = abstractJobType.getManagement().getTimeManagement().getJsPlannedTime().getStartTime() .getTime();//from w w w . ja va2 s .com Date currentTime = Calendar.getInstance().getTime(); if (scheduledTime.before(currentTime)) { return true; } return false; }
From source file:com.dattasmoon.pebble.plugin.FireReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { if (com.twofortyfouram.locale.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) { // fetch this for later, we may need it in case we change things // around and we need to know what version of the code they were // running when they saved the action int bundleVersionCode = intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_VERSION_CODE, 1); Type type = Type.values()[intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_TYPE, Type.NOTIFICATION.ordinal())]; PowerManager pm;//from w ww . ja v a 2s . c om switch (type) { case NOTIFICATION: SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); // handle screen DND boolean notifScreenOn = sharedPref.getBoolean(Constants.PREFERENCE_NOTIF_SCREEN_ON, true); pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "FireReceiver.onReceive: notifScreenOn=" + notifScreenOn + " screen=" + pm.isScreenOn()); } if (!notifScreenOn && pm.isScreenOn()) { break; } //handle quiet hours DND boolean quiet_hours = sharedPref.getBoolean(Constants.PREFERENCE_QUIET_HOURS, false); //we only need to pull this if quiet hours are enabled. Save the cycles for the cpu! (haha) if (quiet_hours) { String[] pieces = sharedPref.getString(Constants.PREFERENCE_QUIET_HOURS_BEFORE, "00:00") .split(":"); Date quiet_hours_before = new Date(0, 0, 0, Integer.parseInt(pieces[0]), Integer.parseInt(pieces[1])); pieces = sharedPref.getString(Constants.PREFERENCE_QUIET_HOURS_AFTER, "23:59").split(":"); Date quiet_hours_after = new Date(0, 0, 0, Integer.parseInt(pieces[0]), Integer.parseInt(pieces[1])); Calendar c = Calendar.getInstance(); Date now = new Date(0, 0, 0, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Checking quiet hours. Now: " + now.toString() + " vs " + quiet_hours_before.toString() + " and " + quiet_hours_after.toString()); } if (now.before(quiet_hours_before) || now.after(quiet_hours_after)) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Time is before or after the quiet hours time. Returning."); } break; } } String title = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_TITLE); String body = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_BODY); sendAlertToPebble(context, bundleVersionCode, title, body); break; case SETTINGS: Mode mode = Mode.values()[intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_MODE, Mode.OFF.ordinal())]; String packageList = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_PACKAGE_LIST); setNotificationSettings(context, bundleVersionCode, mode, packageList); break; } } }
From source file:biz.wolschon.fileformats.gnucash.jwsdpimpl.GnucashAccountWritingImpl.java
/** * Get the sum of all transaction-splits * affecting this account in the given time-frame. * @param from when to start, inclusive//from ww w . j av a 2s . co m * @param to when to stop, exlusive. * @return the sum of all transaction-splits * affecting this account in the given time-frame. */ public FixedPointNumber getBalanceChange(final Date from, final Date to) { FixedPointNumber retval = new FixedPointNumber(); for (Object element : getTransactionSplits()) { GnucashTransactionSplit split = (GnucashTransactionSplit) element; Date whenHappened = split.getTransaction().getDatePosted(); if (!whenHappened.before(to)) { continue; } if (whenHappened.before(from)) { continue; } retval = retval.add(split.getQuantity()); } return retval; }
From source file:views.Student_Home.java
private void populateTasks() { ArrayList taskList = studentActions.fetchTasks(); while (taskModel.getRowCount() != 0) { taskModel.removeRow(taskModel.getRowCount() - 1); }/*from w ww. j a v a 2 s. c o m*/ Task task = new Task(); Date currDate = new Date(); int totalTime = 0; int timePassed = 0; for (int i = 0; i < taskList.size(); i++) { task = (Task) taskList.get(i); this.taskLinkedList.add(task.getTaskId()); if (currDate.before(task.getStartDate())) { String[] str = { task.getTaskId(), task.getTaskDescription(), task.getProjectId(), "Up coming" }; taskModel.insertRow(taskModel.getRowCount(), str); } else { String[] str = { task.getTaskId(), task.getTaskDescription(), task.getProjectId(), "In progress" }; taskModel.insertRow(taskModel.getRowCount(), str); timePassed = timePassed + (currDate.getDate() - task.getStartDate().getDate()); } totalTime = totalTime + (task.getEndDate().getDate() - task.getStartDate().getDate()); } DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Task completed", timePassed); dataset.setValue("Pending Tasks", totalTime - timePassed); JFreeChart taskStatusChart = ChartFactory.createPieChart("Tasks completion status", dataset, true, true, true); PiePlot piePlot = (PiePlot) taskStatusChart.getPlot(); ChartPanel chartPanel = new ChartPanel(taskStatusChart); chartPanel.setSize(323, 303); chartPanel.setVisible(true); //chartPanel.setLocation(500, 200); taskPieChart.removeAll(); taskPieChart.add(chartPanel); taskPieChart.updateUI(); taskPieChart.repaint(); }
From source file:org.yamj.core.service.metadata.online.TheTVDbScanner.java
private Date getSeasonYear(String seriesId, int season) { List<Episode> episodeList = tvdbApiWrapper.getSeasonEpisodes(seriesId, season); if (CollectionUtils.isEmpty(episodeList)) { return null; }/* w ww.j a v a 2s . co m*/ Date yearDate = null; for (Episode episode : episodeList) { if (StringUtils.isNotBlank(episode.getFirstAired())) { Date parsedDate = MetadataTools.parseToDate(episode.getFirstAired().trim()); if (parsedDate != null) { if (yearDate == null) { yearDate = parsedDate; } else if (parsedDate.before(yearDate)) { yearDate = parsedDate; } } } } return yearDate; }
From source file:com.intuit.tank.report.JobReport.java
/** * @param all// w w w . jav a 2 s .co m */ private void filterDate(List<JobInstance> all) { Date date = jobReportOptions.getStartTime(); if (date != null) { for (Iterator<JobInstance> iter = all.iterator(); iter.hasNext();) { JobInstance job = iter.next(); Date st = job.getStartTime() != null ? job.getStartTime() : job.getCreated(); if (!date.before(st)) { iter.remove(); } } } date = jobReportOptions.getEndTime(); if (date != null) { for (Iterator<JobInstance> iter = all.iterator(); iter.hasNext();) { JobInstance job = iter.next(); Date st = job.getStartTime() != null ? job.getStartTime() : job.getCreated(); if (!date.after(st)) { iter.remove(); } } } if (NumberUtils.isDigits(jobReportOptions.getMinUsers())) { try { int users = Integer.parseInt(jobReportOptions.getMinUsers()); for (Iterator<JobInstance> iter = all.iterator(); iter.hasNext();) { JobInstance job = iter.next(); if (job.getTotalVirtualUsers() < users) { iter.remove(); } } } catch (NumberFormatException e) { LOG.warn("Error with min users value of " + jobReportOptions.getMinUsers()); } } if (NumberUtils.isDigits(jobReportOptions.getMaxUsers())) { try { int users = Integer.parseInt(jobReportOptions.getMaxUsers()); for (Iterator<JobInstance> iter = all.iterator(); iter.hasNext();) { JobInstance job = iter.next(); if (job.getTotalVirtualUsers() > users) { iter.remove(); } } } catch (NumberFormatException e) { LOG.warn("Error with max users value of " + jobReportOptions.getMaxUsers()); } } if (NumberUtils.isDigits(jobReportOptions.getJobIdStart())) { try { int jobIdStart = NumberUtils.toInt(jobReportOptions.getJobIdStart()); for (Iterator<JobInstance> iter = all.iterator(); iter.hasNext();) { JobInstance job = iter.next(); if (job.getId() < jobIdStart) { iter.remove(); } } } catch (NumberFormatException e) { LOG.warn("Error with max users value of " + jobReportOptions.getMaxUsers()); } } if (NumberUtils.isDigits(jobReportOptions.getJobIdEnd())) { try { int jobIdStart = NumberUtils.toInt(jobReportOptions.getJobIdEnd()); for (Iterator<JobInstance> iter = all.iterator(); iter.hasNext();) { JobInstance job = iter.next(); if (job.getId() > jobIdStart) { iter.remove(); } } } catch (NumberFormatException e) { LOG.warn("Error with max users value of " + jobReportOptions.getMaxUsers()); } } }