List of usage examples for java.util Date after
public boolean after(Date when)
From source file:fr.paris.lutece.plugins.crm.web.demand.DemandTypeJspBean.java
/** * Search the list of demand type/*www . j a v a 2 s. c om*/ * @param request {@link HttpServletRequest} * @return a list of {@link DemandType} */ private List<DemandType> doSearchDemandTypesList(HttpServletRequest request) { String strSearch = request.getParameter(CRMConstants.PARAMETER_SEARCH); if (StringUtils.isNotBlank(strSearch) || (_dtFilter == null)) { _dtFilter = new DemandTypeFilter(); String strLabel = request.getParameter(CRMConstants.PARAMETER_LABEL); String strUrlForm = request.getParameter(CRMConstants.PARAMETER_URL_RESOURCE); String strIdCategory = request.getParameter(CRMConstants.PARAMETER_CATEGORY_ID_CATEGORY); String strDateBegin = request.getParameter(CRMConstants.PARAMETER_DATE_BEGIN); String strDateEnd = request.getParameter(CRMConstants.PARAMETER_DATE_END); String strOperatorDateBegin = request.getParameter(CRMConstants.PARAMETER_OPERATOR_DATE_BEGIN); String strOperatorDateEnd = request.getParameter(CRMConstants.PARAMETER_OPERATOR_DATE_END); String strUrlDelete = request.getParameter(CRMConstants.PARAMETER_URL_DELETE); if (StringUtils.isNotBlank(strLabel)) { _dtFilter.setLabel(strLabel); } if (StringUtils.isNotBlank(strUrlForm)) { _dtFilter.setUrlResource(strUrlForm); } if (StringUtils.isNotBlank(strIdCategory) && StringUtils.isNumeric(strIdCategory)) { int nIdCategory = Integer.parseInt(strIdCategory); _dtFilter.setIdCategory(nIdCategory); } if (StringUtils.isNotBlank(strDateBegin)) { Date dateBegin = DateUtil.formatDateLongYear(strDateBegin, getLocale()); if (dateBegin != null) { if (dateBegin.after(new Date(0))) { _dtFilter.setDateBegin(dateBegin); } } } if (StringUtils.isNotBlank(strDateEnd)) { Date dateEnd = DateUtil.formatDateLongYear(strDateEnd, getLocale()); if (dateEnd != null) { if (dateEnd.after(new Date(0))) { _dtFilter.setDateEnd(dateEnd); } } } if (StringUtils.isNotBlank(strOperatorDateBegin) && StringUtils.isNumeric(strOperatorDateBegin)) { int nIdOperatorDateBegin = Integer.parseInt(strOperatorDateBegin); if (nIdOperatorDateBegin < OperatorEnum.values().length) { _dtFilter.setOperatorDateBegin(OperatorEnum.values()[nIdOperatorDateBegin]); } } if (StringUtils.isNotBlank(strOperatorDateEnd) && StringUtils.isNumeric(strOperatorDateBegin)) { int nIdOperatorDateEnd = Integer.parseInt(strOperatorDateEnd); if (nIdOperatorDateEnd < OperatorEnum.values().length) { _dtFilter.setOperatorDateEnd(OperatorEnum.values()[nIdOperatorDateEnd]); } } if (StringUtils.isNotBlank(strUrlDelete)) { _dtFilter.setUrlDelete(strUrlDelete); } } return _demandTypeService.findByFilter(_dtFilter); }
From source file:edu.mayo.cts2.framework.plugin.service.bioportal.rest.BioportalRestService.java
/** * Gets the updated ontologies.//from w ww .jav a2 s . co m * * @param feed the feed * @param fromDate the from date * @return the updated ontologies */ protected List<String> getUpdatedOntologies(SyndFeed feed, Date fromDate) { List<String> ontologyIdList = new ArrayList<String>(); for (Object entry : feed.getEntries()) { SyndEntry syndEntry = (SyndEntry) entry; DateModule date = (DateModule) syndEntry.getModule(DateModule.URI); Date foundDate = date.getDate(); if (foundDate.after(foundDate)) { ontologyIdList.add(StringUtils.substringAfterLast(syndEntry.getLink(), "/")); } } return ontologyIdList; }
From source file:com.enonic.cms.core.content.ContentEntity.java
private boolean isAvailableByDateTime(Date date) { if (availableFrom == null) { return false; }//from w w w. j a va2 s.c o m if (availableFrom.after(date)) { return false; } if (availableTo != null) { if (date.after(availableTo) || date.equals(availableTo)) { return false; } } return true; }
From source file:edu.stanford.muse.index.IndexUtils.java
public static List<DatedDocument> selectDocsByDateRange(Collection<DatedDocument> c, int startY, int startM, int startD, int endY, int endM, int endD) { Pair<Date, Date> p = CalendarUtil.getDateRange(startY, startM - 1, startD, endY, endM - 1, endD); Date startDate = p.getFirst(), endDate = p.getSecond(); List<DatedDocument> result = new ArrayList<>(); for (DatedDocument d : c) { //we want docs with the same date (year, month, date) or after start date SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); if (!startDate.after(d.date) && !endDate.before(d.date)) result.add(d);/*from w w w .j a v a 2s . c om*/ } // Collections.sort(result); return result; }
From source file:com.lottery.gui.MainLotteryForm.java
private void btnBuyTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuyTicketActionPerformed if (StringUtils.isBlank(tfBuyerName.getText().trim())) { JOptionPane.showMessageDialog(this, "Buyer name is blank!"); tfBuyerName.requestFocusInWindow(); return;/*from w ww . j ava 2 s.c o m*/ } if (StringUtils.isBlank(ftfBuyStartDate.getText().trim())) { JOptionPane.showMessageDialog(this, "Start date is invalid (dd/MM/yyyy)!"); ftfBuyStartDate.requestFocusInWindow(); return; } Date startDate = null; try { startDate = LotteryUtils.getDate(ftfBuyStartDate.getText().trim()); } catch (ParseException ex) { JOptionPane.showMessageDialog(this, "Start date is invalid (dd/MM/yyyy)!"); ftfBuyStartDate.requestFocusInWindow(); LOGGER.error(ex); return; } Date targetDate = LotteryUtils.getTargetDate(startDate); Date today = new Date(); if (today.after(startDate)) { JOptionPane.showMessageDialog(this, "Start date must be greater than today!"); tfBuyerName.requestFocusInWindow(); return; } int dialogResult = JOptionPane.showConfirmDialog(this, "Would You Like to generate ticket for: " + tfBuyerName.getText() + "?", "Warning", JOptionPane.YES_OPTION); if (dialogResult == JOptionPane.NO_OPTION) { return; } // Date today = new Date(); // Date startDate = LotteryUtils.getNextDate(today); // int startDay = LotteryUtils.getDayOfMonth(startDate); // int maxDayOfMonth = LotteryUtils.getLastDayOfMonth(startDate); // // buyerService.getAll(); Buyer buyer = new Buyer(); buyer.setName(tfBuyerName.getText().trim()); buyer.setIc(tfBuyerIc.getText().trim()); List<String> linesBallsDb = new ArrayList<>(); List<Ticket> newTickets = new ArrayList<>(); Date queryDate = startDate; int count = 0; try { // for (int dayOfMonth = startDay; dayOfMonth <= maxDayOfMonth; dayOfMonth++) { for (; queryDate.before(targetDate);) { List<TicketTable> ticketTables = ticketTableService.getByDate(queryDate); linesBallsDb = LotteryUtils.getAllLinesBalls(ticketTables); Ticket newTicket = LotteryUtils.generateTicket(linesBallsDb, queryDate, count++); newTicket.setBuyer(buyer); newTickets.add(newTicket); queryDate = LotteryUtils.getNextDate(queryDate); } buyer.setTickets(newTickets); LotteryUtils.generatePhysicalTicket(buyer, System.currentTimeMillis() + "_" + buyer.getName() + ".xls"); buyerService.saveOrUpdate(buyer); JOptionPane.showMessageDialog(this, "Generate ticket successfully for " + tfBuyerName.getText() + "!"); btnResetActionPerformed(null); } catch (LotteryException ex) { LOGGER.error("Generate ticket exception: ", ex); JOptionPane.showMessageDialog(this, "Please help to try again!"); } catch (Exception ex2) { LOGGER.error("Generate ticket exception: ", ex2); JOptionPane.showMessageDialog(this, "Something goes wrong! Please try again or report to administrator!"); } }
From source file:org.ambientdynamix.contextplugins.withingsdataplugin.WithingsDataPluginRuntime.java
/** * start the process by loging in, finding the right user and * retreiving the values, then submitting the new values. * /*from w w w . j av a 2 s .co m*/ * the method is loop that sleeps a while in between. * * a new context is only pushed if a new value is found. * *@return a array with the values (default 0 if no new value is found) */ private float[] getValues() throws Exception { Log.i("Withings", "getvalues"); Date lastupdate = user.getLastUpdate(); Log.i("Withings", "lastupdate" + lastupdate); Date newlastupdate = lastupdate; String newlastupdatestring = ""; String request = "http://wbsapi.withings.net/measure?action=getmeas&userid=" + id + "&publickey=" + publicKey + //"&limit=10"+ "&devtype=1"; // Only values from the scale String response = performRequest(request); System.out.println(response); // Decode JSon object JSONObject json = new JSONObject(response); JSONArray JSONvalues = json.getJSONObject("body").getJSONArray("measuregrps"); JSONObject JSONvalue; JSONArray JSONtypes; JSONObject JSONtype; long timestamp; float weight = 0; float height = 0; float fatFreeMass = 0; float fatRatio = 0; float fatMassWeight = 0; float diastolicBloodPressure = 0; float systolicBloodPressure = 0; float pulse = 0; int size = JSONvalues.length(); for (int i = 0; i < size; i++) { JSONvalue = JSONvalues.getJSONObject(i); if (JSONvalue.getInt("category") != 1) { continue; } timestamp = JSONvalue.getLong("date"); String stamp = "" + timestamp; Date newdate = new Date(Long.parseLong(stamp) * 1000); System.out.println(timestamp); if (newdate.after(newlastupdate)) { Log.i("Withings", "newdate " + newdate); newlastupdate = newdate; newlastupdatestring = stamp; } if (newdate.after(lastupdate)) { //Log.i("Withings", "newdate after lastupdate"); JSONtypes = JSONvalue.getJSONArray("measures"); for (int j = 0; j < JSONtypes.length(); j++) { JSONtype = JSONtypes.getJSONObject(j); //1 Weight (kg) //4 Height (meter) //5 Fat Free Mass (kg) //6 Fat Ratio (%) //8 Fat Mass Weight (kg) //9 Diastolic Blood Pressure (mmHg) //10 Systolic Blood Pressure (mmHg) //11 Heart Pulse (bpm) if (JSONtype.getInt("type") == 1) { if (weight == 0) { Log.i("Withings", "" + weight); weight = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); Log.i("Withings", "" + weight); } } if (JSONtype.getInt("type") == 2) { //not used yet } if (JSONtype.getInt("type") == 3) { //not used yet } if (JSONtype.getInt("type") == 4) { if (height == 0) { height = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 5) { if (fatFreeMass == 0) { fatFreeMass = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 6) { if (fatRatio == 0) { fatRatio = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 7) { //not used yet } if (JSONtype.getInt("type") == 8) { if (fatMassWeight == 0) { fatMassWeight = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 9) { if (diastolicBloodPressure == 0) { diastolicBloodPressure = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 10) { if (systolicBloodPressure == 0) { systolicBloodPressure = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 11) { if (pulse == 0) { pulse = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } } } } request = "http://wbsapi.withings.net/measure?action=getmeas&userid=" + id + "&publickey=" + publicKey + "&limit=10" + "&devtype=0"; // Only values from the scale response = performRequest(request); System.out.println(response); json = new JSONObject(response); JSONvalues = json.getJSONObject("body").getJSONArray("measuregrps"); size = JSONvalues.length(); for (int i = 0; i < size; i++) { JSONvalue = JSONvalues.getJSONObject(i); if (JSONvalue.getInt("category") != 1) { continue; } timestamp = JSONvalue.getLong("date"); String stamp = "" + timestamp; Date newdate = new Date(); System.out.println(timestamp); try { newdate = new Date(Long.parseLong(stamp) * 1000); if (newdate.after(newlastupdate)) { Log.i("Withings", "newdate2 " + newdate); newlastupdate = newdate; newlastupdatestring = stamp; } } catch (Exception ex) { ex.getStackTrace(); } if (newdate.after(lastupdate)) { JSONtypes = JSONvalue.getJSONArray("measures"); for (int j = 0; j < JSONtypes.length(); j++) { JSONtype = JSONtypes.getJSONObject(j); if (JSONtype.getInt("type") == 1) { if (weight == 0) { weight = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 2) { //not used yet } if (JSONtype.getInt("type") == 3) { //not used yet } if (JSONtype.getInt("type") == 4) { if (height == 0) { Log.i("Withings h", "" + height); height = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); Log.i("Withings h", "" + height); } } if (JSONtype.getInt("type") == 5) { if (fatFreeMass == 0) { fatFreeMass = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 6) { if (fatRatio == 0) { fatRatio = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 7) { //not used yet } if (JSONtype.getInt("type") == 8) { if (fatMassWeight == 0) { fatMassWeight = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 9) { if (diastolicBloodPressure == 0) { diastolicBloodPressure = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 10) { if (systolicBloodPressure == 0) { systolicBloodPressure = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } if (JSONtype.getInt("type") == 11) { if (pulse == 0) { pulse = (float) (JSONtype.getInt("value") * Math.pow(10, JSONtype.getInt("unit"))); } } } } } float[] values = new float[8]; values[0] = weight; values[1] = height; values[2] = fatFreeMass; values[3] = fatRatio; values[4] = fatMassWeight; values[5] = diastolicBloodPressure; values[6] = systolicBloodPressure; values[7] = pulse; Log.i("Withings", "Als neuer Timestamp wird bergeben:" + newlastupdatestring); user.update(newlastupdatestring, values); return values; }
From source file:com.redhat.rhn.frontend.action.errata.ErrataSearchAction.java
private List<ErrataOverview> filterByIssueDate(List<ErrataOverview> unfiltered, Date startDate, Date endDate) { if (LOG.isDebugEnabled()) { LOG.debug("Filtering " + unfiltered.size() + " records based on Issue Date"); LOG.debug("Allowed issue date range is " + startDate + " to " + endDate); }/*from w w w .j a va 2 s. c o m*/ List<ErrataOverview> filteredByIssueDate = new ArrayList<ErrataOverview>(); for (ErrataOverview eo : unfiltered) { if (!startDate.after(eo.getIssueDateObj()) && !eo.getIssueDateObj().after(endDate)) { filteredByIssueDate.add(eo); } } return filteredByIssueDate; }
From source file:net.chaosserver.timelord.data.TimelordTask.java
/** * Checks if the task already has some hours tracked for today. * * @return if there is a task for today/* ww w . jav a2 s . c o m*/ */ public boolean isTodayPresent() { boolean todayPresent = false; List<TimelordTaskDay> taskList = getTaskDayList(); if ((taskList != null) && !taskList.isEmpty()) { Date todayDate = DateUtil.trunc(new Date()); TimelordTaskDay taskDay = (TimelordTaskDay) taskList.get(0); Date taskDayDate = taskDay.getDate(); if (taskDayDate != null) { if (log.isTraceEnabled()) { log.trace("Testing taskDayDate [" + this.getTaskName() + "] [" + taskDayDate.getTime() + "] against today [" + todayDate.getTime() + "]"); } if (taskDayDate.equals(todayDate) || taskDayDate.after(todayDate)) { todayPresent = true; } } else { if (log.isWarnEnabled()) { log.warn("Empty date field. Removing taskDay."); taskList.remove(taskDay); } } } return todayPresent; }
From source file:org.pluroid.pluroium.PlurkHelper.java
public boolean isLoginned() { boolean loginned = false; if (cookieStore != null) { List<Cookie> cookies = cookieStore.getCookies(); if (cookies.size() > 0) { BasicClientCookie c = (BasicClientCookie) cookies.get(0); Date expiryDate = c.getExpiryDate(); Date now = Calendar.getInstance().getTime(); if (expiryDate.after(now)) { loginned = true;/* w ww .jav a 2s . c o m*/ } } } return loginned; }
From source file:edu.stanford.muse.index.IndexUtils.java
/** returns list of list of docs organized by a series of time windows */ public static List<Window> docsBySlidingWindow(Collection<EmailDocument> allDocs, int windowSizeInMonths, int stepSizeInMonths) { List<Window> result = new ArrayList<Window>(); if (allDocs.size() == 0) return result; // compute the begin and end date of the corpus Date first = null;// ww w .j a v a2 s . c o m Date last = null; for (EmailDocument ed : allDocs) { Date d = ed.date; if (d == null) { // drop this ed log.warn("Warning: null date on email: " + ed.getHeader()); continue; } if (first == null || d.before(first)) first = d; if (last == null || d.after(last)) last = d; } // compute the monthly intervals List<Pair<Date, Date>> intervals = Util.getSlidingMonthlyIntervalsBackward(first, last, windowSizeInMonths, stepSizeInMonths); int nIntervals = intervals.size(); for (int i = 0; i < nIntervals; i++) { Window w = new Window(); w.start = intervals.get(i).getFirst(); w.end = intervals.get(i).getSecond(); w.docs = new ArrayList<EmailDocument>(); result.add(w); } // for each message, add it to all intervals it belongs to // can be made more efficient by first sorting allDocs by date etc // but may not be needed except for a very large # of intervals and // a large # of docs for (EmailDocument ed : allDocs) { Date d = ed.date; if (d == null) continue; // add ed to all intervals that c falls in for (int i = 0; i < nIntervals; i++) { Pair<Date, Date> interval = intervals.get(i); Date intervalStart = interval.getFirst(); Date intervalEnd = interval.getSecond(); if (d.equals(intervalStart) || d.equals(intervalEnd) || (d.after(intervalStart) && d.before(intervalEnd))) { result.get(i).docs.add(ed); break; } } } return result; }