List of usage examples for java.util Date before
public boolean before(Date when)
From source file:com.vmware.identity.openidconnect.server.SolutionUserAuthenticator.java
private SolutionUser retrieveSolutionUser(String tenant, String certSubjectDn) throws ServerException { com.vmware.identity.idm.SolutionUser idmSolutionUser; try {//w ww . j a v a 2 s . co m idmSolutionUser = this.idmClient.findSolutionUserByCertDn(tenant, certSubjectDn); } catch (Exception e) { throw new ServerException(ErrorObject.serverError("idm error while retrieving solution user"), e); } if (idmSolutionUser == null || idmSolutionUser.getId() == null || idmSolutionUser.getCert() == null) { throw new ServerException( ErrorObject.invalidRequest("solution user with specified cert subject dn not found")); } if (idmSolutionUser.isDisabled()) { throw new ServerException(ErrorObject.accessDenied("solution user has been disabled or deleted")); } Date now = new Date(); if (now.before(idmSolutionUser.getCert().getNotBefore()) || now.after(idmSolutionUser.getCert().getNotAfter())) { throw new ServerException(ErrorObject.accessDenied("cert has expired")); } return new SolutionUser(idmSolutionUser.getId(), tenant, idmSolutionUser.getCert()); }
From source file:ManualInvalidate.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); HttpSession session = req.getSession(); // Invalidate the session if it's more than a day old or has been // inactive for more than an hour. if (!session.isNew()) { // skip new sessions Date dayAgo = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000); Date hourAgo = new Date(System.currentTimeMillis() - 60 * 60 * 1000); Date created = new Date(session.getCreationTime()); Date accessed = new Date(session.getLastAccessedTime()); if (created.before(dayAgo) || accessed.before(hourAgo)) { session.invalidate();// ww w . j a v a2s . c o m session = req.getSession(); // get a new session } } }
From source file:org.opensafety.hishare.managers.implementation.http.ParcelManagerImpl.java
private boolean notExpired(Parcel parcel) { Date expiration = parcel.getExpirationDate(); Date now = Calendar.getInstance().getTime(); return now.before(expiration); }
From source file:cn.vlabs.umt.services.ticket.impl.TicketServiceImpl.java
private boolean isValid(Date start) { Date deadline = DateUtils.addMinutes(start, lifetime); return start.before(deadline); }
From source file:com.salesmanager.core.util.ProductUtil.java
public static BigDecimal determinePriceWithAttributes(Product product, Collection attributes, Locale locale, String currency) {//from w w w . java2 s . com int decimalPlace = 2; Map currenciesmap = RefCache.getCurrenciesListWithCodes(); Currency c = (Currency) currenciesmap.get(currency); // prices BigDecimal bdprodprice = product.getProductPrice(); BigDecimal bddiscountprice = null; // discount price Special special = product.getSpecial(); Date dt = new Date(); java.util.Date spdate = null; java.util.Date spenddate = null; if (special != null) { spdate = special.getSpecialDateAvailable(); spenddate = special.getExpiresDate(); if (spdate.before(new Date(dt.getTime())) && spenddate.after(new Date(dt.getTime()))) { bddiscountprice = special.getSpecialNewProductPrice(); } } // all other prices Set prices = product.getPrices(); if (prices != null) { Iterator pit = prices.iterator(); while (pit.hasNext()) { ProductPrice pprice = (ProductPrice) pit.next(); pprice.setLocale(locale); if (pprice.isDefaultPrice()) {// overwrites default price bddiscountprice = null; spdate = null; spenddate = null; bdprodprice = pprice.getProductPriceAmount(); ProductPriceSpecial ppspecial = pprice.getSpecial(); if (ppspecial != null) { if (ppspecial.getProductPriceSpecialStartDate() != null && ppspecial.getProductPriceSpecialEndDate() != null && ppspecial.getProductPriceSpecialStartDate().before(new Date(dt.getTime())) && ppspecial.getProductPriceSpecialEndDate().after(new Date(dt.getTime()))) { bddiscountprice = ppspecial.getProductPriceSpecialAmount(); } else if (ppspecial.getProductPriceSpecialDurationDays() > -1) { bddiscountprice = ppspecial.getProductPriceSpecialAmount(); } } break; } } } double fprodprice = 0; ; if (bdprodprice != null) { fprodprice = bdprodprice.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP).doubleValue(); } // determine any properties prices BigDecimal attributesPrice = null; if (attributes != null) { Iterator i = attributes.iterator(); while (i.hasNext()) { ProductAttribute attr = (ProductAttribute) i.next(); if (!attr.isAttributeDisplayOnly() && attr.getOptionValuePrice().longValue() > 0) { if (attributesPrice == null) { attributesPrice = new BigDecimal(0); } attributesPrice = attributesPrice.add(attr.getOptionValuePrice()); } } } if (bddiscountprice != null) { if (attributesPrice != null) { bddiscountprice = bddiscountprice.add(attributesPrice); } return bddiscountprice; } else { if (attributesPrice != null) { bdprodprice = bdprodprice.add(attributesPrice); } return bdprodprice; } }
From source file:lolthx.autohome.buy.AutohomePriceListFetch.java
private boolean between(Date beginDate, Date endDate, Date src) { return beginDate.before(src) && endDate.after(src); }
From source file:com.haulmont.timesheets.listener.TimeEntryListener.java
protected void checkClosedPeriods(Date date) { Date openPeriodStart = workTimeConfig.getOpenPeriodStart(); if (openPeriodStart != null && date.before(openPeriodStart)) { throw new ClosedPeriodException("You can not modify time entries in closed periods"); }/* w w w .ja va2s . c o m*/ }
From source file:cn.vlabs.umt.services.session.impl.LoginRecord.java
public void logout(Date deadline) { Date timeout = DateUtils.addMinutes(lastupdate, 30); if (timeout.before(deadline)) { String sessionkey = sessionkeys.get(appType); if (sessionkey != null) { GetMethod method = new GetMethod(logoutURL); method.setRequestHeader("Connection", "close"); method.setRequestHeader("Cookie", sessionkey + "=" + appSessionid); HttpClient client = new HttpClient(); try { client.executeMethod(method); } catch (Exception e) { } finally { client.getHttpConnectionManager().closeIdleConnections(0); }//from ww w . j av a2s . c om } } }
From source file:br.com.surittec.surivalidation.validator.DateRangeValidator.java
@Override public boolean isValid(Date value, ConstraintValidatorContext context) { if (nullable && value == null) return true; if ((minDate == null || !value.before(minDate)) && (maxDate == null || !value.after(maxDate))) { return true; }//from ww w . j a va2 s .c o m return false; }
From source file:com.china317.gmmp.gmmp_report_analysis.App.java
private static void analysisBanche(String yyyyMMdd, ApplicationContext context) { try {//from w ww . j a va2s . com String businessType = "2"; // System.out.println("[classpath]"+System.getProperty("java.class.path"));//classpaht // System.out.println("[path]"+System.getProperty("user.dir"));//? log.info("[get baseVehicle begin---------]"); VehicleDao vehicleDao = (VehicleDao) context.getBean("vehicleDao"); List<Vehicle> vehs = vehicleDao.getBaseVehicleByDate(yyyyMMdd, businessType); List<List<Vehicle>> list_tm = ListUtil.splitList(vehs, 400); log.info("[get baseVehicle end1---------],vehicle total:" + vehs.size()); log.info("[get baseVehicle end2---------],list_tm total:" + list_tm.size()); for (List<Vehicle> vls : list_tm) { Map<String, Vehicle> vehMap = new HashMap<String, Vehicle>(); log.info("[code set init------]"); HashSet<String> codes = new HashSet<String>(); for (Vehicle v : vls) { codes.add(v.getCode()); vehMap.put(v.getCode(), v); } log.info("[code set end------]" + "setSize:" + vehMap.size()); List<VehicleLocate> list = new ArrayList<VehicleLocate>(); if (codes.size() > 0) { VehicleLocateDao vehicleLocateDao_gmmpraw = (VehicleLocateDao) context .getBean("vehicleLocateDaoGmmpRaw"); list = vehicleLocateDao_gmmpraw.findHistoryByParams(yyyyMMdd, codes); log.info("[this time total Points Size]:" + list.size()); } Map<String, List<VehicleLocate>> map = new HashMap<String, List<VehicleLocate>>(); for (VehicleLocate entity : list) { if (entity.getGpsSpeed() < 160) { // businessType Vehicle tmpV = vehMap.get(entity.getCode()); entity.setBusinessType(tmpV.getBusinessType()); List<VehicleLocate> records = map.get(entity.getCode()); if (records == null) { records = new ArrayList<VehicleLocate>(); } long lastlong = DateTime.accountTime3(entity.getGpsTime(), entity.getGetTime()); if (lastlong <= 10 * 60) { records.add(entity); } map.put(entity.getCode(), records); } } log.info("analysis begin ,total:" + map.size()); Iterator<String> it = map.keySet().iterator(); while (it.hasNext()) { String key = it.next(); List<VehicleLocate> tmps = map.get(key); log.info("analysis vehicle code:" + key + "sort list begin, list size:" + tmps.size()); Collections.sort(tmps, new Comparator<VehicleLocate>() { public int compare(VehicleLocate o1, VehicleLocate o2) { Date d1 = o1.getGpsTime(); Date d2 = o2.getGpsTime(); if (d1.after(d2)) { return 1; } else if (d1.before(d2)) { return -1; } else { return 0; } } }); log.info("analysis vehicle code:" + key + "sort list end"); log.info("analysis vehicle code:" + key + "OVERSPEED OFFLINE ANALYSIS begin"); for (int i = 0; i < tmps.size(); i++) { VehicleLocate e = tmps.get(i); AreaAddProcessor.addAreaRuleInfo(e); /* * log.info("[vehcilelocate properties]" + e.getCode() + * "; gpstime:" + e.getGpsTime() + "; gpsSpeed:" + * e.getGpsSpeed() + "; businessType:" + * e.getBusinessType() + "; lon:" + e.getLon() + * "; lat:" + e.getLat() + "; acc:" + e.getACCState()); */ PtmAnalysisImp.getInstance().overSpeedAnalysis(e); // PtmAnalysisImp.getInstance().offlineAnalysis(e, // yyyyMMdd); // ? PtmAnalysisImp.getInstance().putLastRecord(e); } log.info("analysis vehicle code:" + key + "OVERSPEED OFFLINE ANALYSIS end"); log.info("result: overspeed:" + PtmAnalysisImp.getInstance().getOverSpeedRecordsSize() + "; offline:" + PtmAnalysisImp.getInstance().getOfflineRecordsSize()); // PtmAnalysisImp.getInstance().clear(); } // OverSpeedRecordsStoreIntoDB(PtmAnalysisImp.getInstance() // .getOverSpeedRecords(), context); PtmOverSpeedRecordsStoreIntoDB(PtmAnalysisImp.getInstance().getOverSpeedRecords(), context); } log.info("analysis end"); log.info("[Ptm ended]"); } catch (Exception e) { log.error(e); } }