public static Date getNextDateAtHour(int hour) { final GregorianCalendar now = new GregorianCalendar(); final GregorianCalendar nextDate = new GregorianCalendar(); // not truncating minutes to distribute load more evenly when multiple instances are started nextDate.set(Calendar.HOUR_OF_DAY, hour); if (nextDate.before(now)) { nextDate.add(Calendar.DAY_OF_YEAR, 1); } return nextDate.getTime(); }
if (clone.before(this)) { result--;
public synchronized SVersion getOnlineVersion() { if (lastCheck == null || lastCheck.before(getReferenceDate())) { LOGGER.info("Fetching online version info"); try {
while (end.before(current) && !valid) {
while (end.before(current) && !valid) {
public boolean isExpired() { if (nonExpiring) { return false; } return expires.toGregorianCalendar().before(new GregorianCalendar()); }
public boolean isExpired() { if (nonExpiring) { return false; } return expires.toGregorianCalendar().before(new GregorianCalendar()); }
/** * Determines and answers if the given {@code Date} is tomorrow. * * @param date the date to check * @return {@code true} if tomorrow, {@code false} otherwise */ public static boolean isTomorrow(Date date) { GregorianCalendar in = new GregorianCalendar(); in.setTime(date); Calendar tomorrow = getRelativeCalendar(+1); Calendar dayAfter = getRelativeCalendar(+2); return !in.before(tomorrow) && in.before(dayAfter); }
public boolean before(Date anotherDate){ return (this.calendar.before(anotherDate.getCalendar())); }
/** * Determines and answers if the given <code>Date</code> is today. * * @param date the date to check * @return {@code true} if today, {@code false} otherwise */ public static boolean isToday(Date date) { GregorianCalendar in = new GregorianCalendar(); in.setTime(date); Calendar today = getRelativeCalendar( 0); Calendar tomorrow = getRelativeCalendar(+1); return !in.before(today) && in.before(tomorrow); }
/** * Determines and answers if the given <code>Date</code> is tomorrow. * * @param date the date to check * @return {@code true} if tomorrow, {@code false} otherwise */ public static boolean isTomorrow(Date date) { GregorianCalendar in = new GregorianCalendar(); in.setTime(date); Calendar tomorrow = getRelativeCalendar(+1); Calendar dayAfter = getRelativeCalendar(+2); return !in.before(tomorrow) && in.before(dayAfter); }
/** * Determines and answers if the given {@code Date} is today. * * @param date the date to check * @return {@code true} if today, {@code false} otherwise */ public static boolean isToday(Date date) { GregorianCalendar in = new GregorianCalendar(); in.setTime(date); Calendar today = getRelativeCalendar( 0); Calendar tomorrow = getRelativeCalendar(+1); return !in.before(today) && in.before(tomorrow); }
public int getTimeInService(GregorianCalendar today) { // Get time in service based on year if (null == recruitment) { //use zero if hasn't been recruited yet return -1; } int timeinservice = today.get(Calendar.YEAR) - recruitment.get(Calendar.YEAR); // Add the tentative time in service to the date of recruitment to get this year's service history GregorianCalendar tmpDate = (GregorianCalendar) recruitment.clone(); tmpDate.add(Calendar.YEAR, timeinservice); if (today.before(tmpDate)) { timeinservice--; } return timeinservice; }
public int getAge(GregorianCalendar today) { // Get age based on year if (null != deathday) { //use deathday instead of birthdate today = deathday; } int age = today.get(Calendar.YEAR) - birthday.get(Calendar.YEAR); // Add the tentative age to the date of birth to get this year's birthday GregorianCalendar tmpDate = (GregorianCalendar) birthday.clone(); tmpDate.add(Calendar.YEAR, age); // If this year's birthday has not happened yet, subtract one from age if (today.before(tmpDate)) { age--; } return age; }
public int getAge() { // Get age based on year int age = campaign.getCalendar().get(Calendar.YEAR) - birthdate.get(Calendar.YEAR); // Add the tentative age to the date of birth to get this year's birthday GregorianCalendar tmpDate = (GregorianCalendar) birthdate.clone(); tmpDate.add(Calendar.YEAR, age); // If this year's birthday has not happened yet, subtract one from age if (campaign.getCalendar().before(tmpDate)) { age--; } return age; }
public RandomDateMaker(GregorianCalendar theStart, GregorianCalendar theEnd) { assert theStart.before(theEnd); start = theStart; end = theEnd; seconds = (int) ((end.getTimeInMillis() - start.getTimeInMillis()) / 1000L); }
@Override public void performAction(List<Client> entries) { for (Client client : entries) { try { GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("UTC")); GregorianCalendar expirationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); expirationDate.setTime(client.getClientSecretExpiresAt()); if (expirationDate.before(now)) { List<AuthorizationGrant> toRemove = authorizationGrantList.getAuthorizationGrant(client.getClientId()); authorizationGrantList.removeAuthorizationGrants(toRemove); log.debug("Removing Client: {}, Expiration date: {}", client.getClientId(), client.getClientSecretExpiresAt()); clientService.remove(client); } } catch (Exception e) { log.error("Failed to remove entry", e); } } } };
@Override public boolean filter( final History spec, final int index, final int size, final Stanza message, final Delay delay ) { if( delay == null ) { return false; } final XMLGregorianCalendar since = spec.getSince(); if( since == null || !since.isValid() ) { return false; } final Calendar stamp = delay.getStamp(); return stamp == null ? false : since.toGregorianCalendar().before( stamp ); } };
private boolean hasUnreadNotify(Client client, ArrayList<FavTopic> topics) throws Throwable { Log.d(LOG_TAG, "favorites.hasUnreadNotify="); if (topics.size() == 0 || getNewTopicsCount(topics) == 0) return false; Topic lastPostedTopic = null; for (FavTopic topic : topics) { if (topic.getIsNew() && (!m_PinnedOnly || topic.isPinned())) { lastPostedTopic = topic; break; } } if (lastPostedTopic == null || !lastPostedTopic.getIsNew()) return false; GregorianCalendar lastPostedTopicCalendar = new GregorianCalendar(); lastPostedTopicCalendar.setTime(lastPostedTopic.getLastMessageDate()); GregorianCalendar lastDateTime = loadLastDate(LAST_DATETIME_KEY); if (lastDateTime == null || lastDateTime.before(lastPostedTopicCalendar)) { saveLastDate(lastPostedTopicCalendar, LAST_DATETIME_KEY); return true; } return false; }
/** * Updates the datas about Thread answers. * * @param thread * @param session */ public void updateAnswersOfThread(DocumentModel thread, CoreSession session) { // To force reload of Posts session.save(); // ------------- List<DocumentModel> answers = getCommentManager().getComments(thread); Serializable lastCommentAuthor = thread.getPropertyValue("dc:creator"); GregorianCalendar lastCommentDate = (GregorianCalendar) thread.getPropertyValue("dc:created"); for (DocumentModel answer : answers) { Serializable author = answer.getPropertyValue("post:author"); GregorianCalendar creationDate = (GregorianCalendar) answer.getPropertyValue("post:creationDate"); if (lastCommentDate == null || lastCommentDate.before(creationDate)) { lastCommentDate = creationDate; lastCommentAuthor = author; } } Map<String, Serializable> properties = new HashMap<String, Serializable>(); properties.put(CollabToolsConstants.TTC_THREAD_NB_COMMENTS_XPATH, answers.size()); properties.put(CollabToolsConstants.TTC_THREAD_LAST_COMMENT_DATE_XPATH, lastCommentDate); properties.put(CollabToolsConstants.TTC_THREAD_LAST_COMMENT_AUTHOR_XPATH, lastCommentAuthor); UnrestrictedPropertySetter propertySetter = new UnrestrictedPropertySetter(session, thread.getRef(), properties); propertySetter.runUnrestricted(); }