List of usage examples for java.util Calendar after
public boolean after(Object when)
Calendar
represents a time after the time represented by the specified Object
. From source file:de.hybris.platform.acceleratorservices.web.payment.validation.PaymentDetailsValidator.java
@Override public void validate(final Object object, final Errors errors) { final PaymentDetailsForm form = (PaymentDetailsForm) object; final Calendar start = parseDate(form.getStartMonth(), form.getStartYear()); final Calendar expiration = parseDate(form.getExpiryMonth(), form.getExpiryYear()); final Calendar current = Calendar.getInstance(); if (start.after(current)) { errors.rejectValue("startMonth", "payment.startDate.past.invalid"); }/*from w w w. j av a 2 s .c om*/ if (expiration.before(current)) { errors.rejectValue("expiryMonth", "payment.expiryDate.future.invalid"); } if (start.after(expiration)) { errors.rejectValue("startMonth", "payment.startDate.invalid"); } ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.firstName", "address.firstName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.lastName", "address.lastName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line1", "address.line1.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.townCity", "address.city.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.postcode", "address.postcode.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.countryIso", "address.country.invalid"); }
From source file:es.elearningmedia.courseslastaccess.service.BbServiceImpl.java
@Override public List<CourseLastAccess> getCoursesLastAccess() { List<CourseLastAccess> result = new ArrayList<CourseLastAccess>(); try {//from ww w . j a v a2 s .com List<Course> cursos = CourseDbLoader.Default.getInstance().loadAllCourses(); for (Course curso : cursos) { List<CourseMembership> courseMemberships = CourseMembershipDbLoader.Default.getInstance() .loadByCourseId(curso.getId()); Calendar lastAccess = null; int studentsCount = 0; int instructorsCount = 0; for (CourseMembership courseMembership : courseMemberships) { if (lastAccess == null) { lastAccess = courseMembership.getLastAccessDate(); } else { Calendar access = courseMembership.getLastAccessDate(); if (access != null) { if (access.after(lastAccess)) { lastAccess = courseMembership.getLastAccessDate(); } } } Role role = courseMembership.getRole(); if (role.equals(CourseMembership.Role.STUDENT)) { studentsCount++; } else { instructorsCount++; } } CourseLastAccess courseLastAccess = new CourseLastAccess(); courseLastAccess.setCourse_id(curso.getCourseId()); SimpleDateFormat formatedDate = new SimpleDateFormat("yyyy-MM-dd"); if (lastAccess == null) { courseLastAccess.setLast_access("Never"); courseLastAccess.setDate_sort("0"); } else { courseLastAccess.setLast_access(formatedDate.format(lastAccess.getTime())); courseLastAccess.setDate_sort(Long.toString(lastAccess.getTimeInMillis())); } courseLastAccess.setCreated(formatedDate.format(curso.getCreatedDate().getTime())); String status = "Unavailable"; if (curso.getIsAvailable()) { status = "Available"; } courseLastAccess.setStatus(status); courseLastAccess.setInstructors(Integer.toString(instructorsCount)); courseLastAccess.setStudents(Integer.toString(studentsCount)); courseLastAccess.setSize(Float.toString((getCourseSizes(curso) / 1024f) / 1024f)); result.add(courseLastAccess); } } catch (KeyNotFoundException e) { e.printStackTrace(); } catch (PersistenceException e) { e.printStackTrace(); } //Collections.sort(result); return result; }
From source file:com.orange.oidc.secproxy_service.Token.java
boolean isExpired() { Calendar cal = getExp(); if (cal != null) Log.d("Token", "expiration: " + fromCal(cal)); if (cal != null && cal.after(Calendar.getInstance())) { return false; }/*from w ww . j a v a2 s . c o m*/ return true; }
From source file:com.orange.oidc.tim.service.TokensKeys.java
boolean isRefreshTokenValid() { // return isTokenValid(refresh_token); //[NBAN] TODO verification de l'expiration partir de la chaine de caractre et non le timems qui n'est pas set dans le cas du SDStorage if ((timems == 0) && (this.expires != null)) { Calendar cal = fromStringToDate(this.expires); return cal.after(Calendar.getInstance()); } else if (timems != 0) { Calendar calNow = Calendar.getInstance(); calNow.setTimeZone(TimeZone.getTimeZone("GMT")); long now = calNow.getTimeInMillis(); return timems > now; }/* w w w . j ava 2 s. c o m*/ return false; }
From source file:org.languagetool.rules.AbstractFutureDateFilter.java
/** * @param args a map with values for {@code year}, {@code month}, {@code day} (day of month), {@code weekDay} */// ww w . ja va2 s . co m @Override public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> args, AnalyzedTokenReadings[] patternTokens) { Calendar dateFromDate = getDate(args); Calendar currentDate = getCalendar(); if (TestHackHelper.isJUnitTest()) { currentDate = new Calendar.Builder().setDate(2014, 0, 1).build(); } try { if (dateFromDate.after(currentDate)) { return match; } else { return null; } } catch (IllegalArgumentException ignore) { // happens with 'dates' like '32.8.2014' - those should be caught by a different rule return null; } }
From source file:hu.petabyte.redflags.web.svc.SecuritySvc.java
public boolean validateToken(long id, String token) { if (null == token || token.isEmpty()) { return false; }/* w w w . j av a 2 s . co m*/ Account a = accounts.findOne(id); if (null == a || null == a.getRememberToken() || null == a.getRememberTokenExpiresAt() || a.getRememberToken().isEmpty()) { return false; } Calendar now = Calendar.getInstance(); now.setTime(new Date()); Calendar rememberDate = Calendar.getInstance(); rememberDate.setTime(a.getRememberTokenExpiresAt()); if (!token.equals(a.getRememberToken()) || now.after(rememberDate)) { return false; } else { return true; } }
From source file:org.openhab.binding.zway.handler.ZWayZAutomationDeviceHandler.java
@Override protected void refreshLastUpdate() { logger.debug("Refresh last update for virtual device"); // Check Z-Way bridge handler ZWayBridgeHandler zwayBridgeHandler = getZWayBridgeHandler(); if (zwayBridgeHandler == null || !zwayBridgeHandler.getThing().getStatus().equals(ThingStatus.ONLINE)) { logger.debug("Z-Way bridge handler not found or not ONLINE."); return;/*www . j a v a2 s.co m*/ } // Load and check device from Z-Way server DeviceList deviceList = zwayBridgeHandler.getZWayApi().getDevices(); if (deviceList != null) { Device device = deviceList.getDeviceById(mConfig.getDeviceId()); if (device == null) { logger.debug("ZAutomation device not found."); return; } Calendar lastUpdateOfDevice = Calendar.getInstance(); lastUpdateOfDevice.setTimeInMillis(new Long(device.getUpdateTime()) * 1000); if (lastUpdate == null || lastUpdateOfDevice.after(lastUpdate)) { lastUpdate = lastUpdateOfDevice; } DateFormat formatter = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss"); updateProperty(DEVICE_PROP_LAST_UPDATE, formatter.format(lastUpdate.getTime())); } }
From source file:org.exoplatform.services.jcr.ext.classify.impl.DateTimeClassifyPlugin.java
public void classifyChildrenNode(Node parent) throws Exception { Session session = parent.getSession(); for (NodeIterator nodes = parent.getNodes(); nodes.hasNext();) { Node node = nodes.nextNode(); Calendar calNode = node.getProperty(propertyDateTime).getDate(); if ((calNode.before(startDateTime)) || (calNode.after(endDateTime))) continue; Node currentNode = createNewDateTimeNode(parent, getDateTimeStructured(templateDateTime, calNode)); String srcPath = node.getPath(); String destPath = currentNode.getPath() + "/" + node.getName(); session.move(srcPath, destPath); session.save();/* w ww . j a v a2 s. com*/ } }
From source file:org.linagora.linshare.core.service.impl.UploadRequestEntryUrlServiceImpl.java
private void accessBusinessCheck(UploadRequestEntryUrl requestEntryUrl, String password) throws BusinessException { if (!isValidPassword(requestEntryUrl, password)) { throw new BusinessException(BusinessErrorCode.UPLOAD_REQUEST_URL_FORBIDDEN, "You do not have the right to get this upload request url : " + requestEntryUrl.getUuid()); }// w ww .j ava2s . co m Calendar now = GregorianCalendar.getInstance(); Calendar compare = GregorianCalendar.getInstance(); compare.setTime(requestEntryUrl.getExpiryDate()); if (now.after(compare)) { throw new BusinessException(BusinessErrorCode.UPLOAD_REQUEST_ENTRY_URL_EXPIRED, "The current upload request url is outdated : " + requestEntryUrl.getUuid()); } }
From source file:com.epam.training.storefront.forms.validation.PaymentDetailsValidator.java
@Override public void validate(final Object object, final Errors errors) { final PaymentDetailsForm form = (PaymentDetailsForm) object; final Calendar start = parseDate(form.getStartMonth(), form.getStartYear()); final Calendar expiration = parseDate(form.getExpiryMonth(), form.getExpiryYear()); final Calendar current = Calendar.getInstance(); if (start != null) { if (start.after(current)) { errors.rejectValue("startMonth", "payment.startDate.past.invalid"); }// w w w . java2 s .c om if (expiration != null) { if (start.after(expiration)) { errors.rejectValue("startMonth", "payment.startDate.invalid"); } } } if (expiration != null) { if (expiration.before(current)) { errors.rejectValue("expiryMonth", "payment.expiryDate.future.invalid"); } } final boolean editMode = StringUtils.isNotBlank(form.getPaymentId()); if (editMode || Boolean.TRUE.equals(form.getNewBillingAddress())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.firstName", "address.firstName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.lastName", "address.lastName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line1", "address.line1.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.townCity", "address.townCity.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.postcode", "address.postcode.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.countryIso", "address.country.invalid"); } }