当前位置: 首页>>代码示例>>Java>>正文


Java DateTime.isBefore方法代码示例

本文整理汇总了Java中org.joda.time.DateTime.isBefore方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.isBefore方法的具体用法?Java DateTime.isBefore怎么用?Java DateTime.isBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.DateTime的用法示例。


在下文中一共展示了DateTime.isBefore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isInvasionTime

import org.joda.time.DateTime; //导入方法依赖的package包/类
public boolean isInvasionTime(DateTime startDate, DateTime current) {
    //For the record, the invasion times themselves are NOT random. They are 6 hours on, 12.5 hours off, repeating forever.
    //This gives an invasion happening at every possible hour of the day over a 3 day period.
    DateTime start = new DateTime(startDate);
    boolean loop = true;
    boolean enabled = true;
    while (loop) {
        if (enabled) {
            start = start.plusHours(6);
            if (current.isBefore(start)) {
                loop = false;
            } else {
                enabled = false;
            }
        } else {
            start = start.plusHours(12).plusMinutes(30);
            if (current.isBefore(start)) {
                loop = false;
            } else {
                enabled = true;
            }
        }

    }
    return enabled;
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:27,代码来源:InvasionCommand.java

示例2: filterCurrentYearItems

import org.joda.time.DateTime; //导入方法依赖的package包/类
private List<GameHarvest> filterCurrentYearItems(List<GameHarvest> items) {
    List<GameHarvest> filtered = new ArrayList<>();

    DateTime startDate = DateTimeUtils.getHuntingYearStart(mCalendarYear);
    DateTime endDate = DateTimeUtils.getHuntingYearEnd(mCalendarYear);

    for (GameHarvest event : items) {
        DateTime eventTime = new DateTime(event.mTime);

        if (LogEventBase.TYPE_SRVA.equals(event.mType)) {
            if (eventTime.getYear() == mCalendarYear) {
                filtered.add(event);
            }
        } else {
            if (eventTime.isAfter(startDate) && eventTime.isBefore(endDate)) {
                filtered.add(event);
            }
        }
    }
    return filtered;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:22,代码来源:GameLogFragment.java

示例3: testDateTime

import org.joda.time.DateTime; //导入方法依赖的package包/类
private static boolean testDateTime(DateTime a, String b, RestFilterOperator operator) {
  DateTime bdt = new DateTime(b);
  switch (operator) {
    case EQUALS:
      return a.equals(bdt);
    case LESSER_THAN:
      return a.isBefore(bdt);
    case GREATER_THAN:
      return a.isAfter(bdt);
    default:
      return false;
  }
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:14,代码来源:XmlElementPathBeanPredicate.java

示例4: sanitize

import org.joda.time.DateTime; //导入方法依赖的package包/类
private Http.Request sanitize(Http.Context ctx, JsonNode body) throws SanitizingException {
    Http.Request request = SanitizingHelper.sanitize("roomId", body, Long.class, Attrs.ROOM_ID, ctx.request());
    request = SanitizingHelper.sanitize("examId", body, Long.class, Attrs.EXAM_ID, request);

    // Custom sanitizing ->

    // Optional AIDS (sic!)
    Collection<Integer> aids = new HashSet<>();
    if (body.has("aids")) {
        Iterator<JsonNode> it = body.get("aids").elements();
        while (it.hasNext()) {
            aids.add(it.next().asInt());
        }
    }
    request = request.addAttr(Attrs.ACCESSABILITES, aids);

    // Mandatory start + end dates
    if (body.has("start") && body.has("end")) {
        DateTime start = DateTime.parse(body.get("start").asText(), ISODateTimeFormat.dateTimeParser());
        DateTime end = DateTime.parse(body.get("end").asText(), ISODateTimeFormat.dateTimeParser());
        if (start.isBeforeNow() || end.isBefore(start)) {
            throw new SanitizingException("invalid dates");
        }
        request = request.addAttr(Attrs.START_DATE, start);
        request = request.addAttr(Attrs.END_DATE, end);
    } else {
        throw new SanitizingException("invalid dates");
    }
    return request;
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:31,代码来源:CalendarReservationSanitizer.java

示例5: getLastUpdate

import org.joda.time.DateTime; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
@Nullable public DateTime getLastUpdate() {
    DateTime ret = null;
    for (final ClientInformationResolver resolver : resolvers) {
        if (resolver instanceof RefreshableClientInformationResolver) {
            final DateTime lastUpdate = ((RefreshableClientInformationResolver) resolver).getLastUpdate();
            if (ret == null || ret.isBefore(lastUpdate)) {
                ret = lastUpdate;
            }
        }
    }
    
    return ret;
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:16,代码来源:ChainingClientInformationResolver.java

示例6: markEnded

import org.joda.time.DateTime; //导入方法依赖的package包/类
private void markEnded(List<ExamParticipation> participations) {
    for (ExamParticipation participation : participations) {
        Exam exam = participation.getExam();
        Reservation reservation = participation.getReservation();
        DateTime reservationStart = new DateTime(reservation.getStartAt());
        DateTime participationTimeLimit = reservationStart.plusMinutes(exam.getDuration());
        DateTime now = AppUtil.adjustDST(DateTime.now(), reservation.getMachine().getRoom());
        if (participationTimeLimit.isBefore(now)) {
            participation.setEnded(now);
            participation.setDuration(
                    new DateTime(participation.getEnded().getMillis() - participation.getStarted().getMillis()));

            GeneralSettings settings = SettingsController.getOrCreateSettings("review_deadline", null, "14");
            int deadlineDays = Integer.parseInt(settings.getValue());
            DateTime deadline = new DateTime(participation.getEnded()).plusDays(deadlineDays);
            participation.setDeadline(deadline);

            participation.save();
            Logger.info("{}: ... setting exam {} state to REVIEW", getClass().getCanonicalName(), exam.getId());
            exam.setState(Exam.State.REVIEW);
            exam.save();
            if (exam.isPrivate()) {
                // Notify teachers
                Set<User> recipients = new HashSet<>();
                recipients.addAll(exam.getParent().getExamOwners());
                recipients.addAll(exam.getExamInspections().stream().map(
                        ExamInspection::getUser).collect(Collectors.toSet()));
                AppUtil.notifyPrivateExamEnded(recipients, exam, composer);
            }
        } else {
            Logger.info("{}: ... exam {} is ongoing until {}", getClass().getCanonicalName(), exam.getId(),
                    participationTimeLimit);
        }
    }
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:36,代码来源:ExamAutoSaverActor.java

示例7: getNextTriggerTime

import org.joda.time.DateTime; //导入方法依赖的package包/类
public DateTime getNextTriggerTime() {
    DateTime now = DateTime.now();
    DateTime target = now
            .withHourOfDay(getHourOfDay())
            .withMinuteOfHour(getMinute())
            .withSecondOfMinute(0)
            .withMillisOfSecond(0);

    return target.isBefore(now) ? target.plus(REPEAT_DURATION) : target;
}
 
开发者ID:KevinLiddle,项目名称:crockpod,代码行数:11,代码来源:Alarm.java

示例8: findGaps

import org.joda.time.DateTime; //导入方法依赖的package包/类
public static List<Interval> findGaps(List<Interval> reserved, Interval searchInterval) {
    List<Interval> gaps = new ArrayList<>();
    DateTime searchStart = searchInterval.getStart();
    DateTime searchEnd = searchInterval.getEnd();
    if (hasNoOverlap(reserved, searchStart, searchEnd)) {
        gaps.add(searchInterval);
        return gaps;
    }
    // create a sub-list that excludes interval which does not overlap with
    // searchInterval
    List<Interval> subReservedList = removeNonOverlappingIntervals(reserved, searchInterval);
    DateTime subEarliestStart = subReservedList.get(0).getStart();
    DateTime subLatestEnd = subReservedList.get(subReservedList.size() - 1).getEnd();

    // in case the searchInterval is wider than the union of the existing
    // include searchInterval.start => earliestExisting.start
    if (searchStart.isBefore(subEarliestStart)) {
        gaps.add(new Interval(searchStart, subEarliestStart));
    }

    // get all the gaps in the existing list
    gaps.addAll(getExistingIntervalGaps(subReservedList));

    // include latestExisting.end => searchInterval.end
    if (searchEnd.isAfter(subLatestEnd)) {
        gaps.add(new Interval(subLatestEnd, searchEnd));
    }
    return gaps;

}
 
开发者ID:CSCfi,项目名称:exam,代码行数:31,代码来源:DateTimeUtils.java

示例9: evaluate

import org.joda.time.DateTime; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void evaluate(MessageContext messageContext) throws SecurityPolicyException {
    if (!(messageContext instanceof SAMLMessageContext)) {
        log.debug("Invalid message context type, this policy rule only supports SAMLMessageContext");
        return;
    }
    SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext;

    if (samlMsgCtx.getInboundSAMLMessageIssueInstant() == null) {
        if(requiredRule){
            log.warn("Inbound SAML message issue instant not present in message context");
            throw new SecurityPolicyException("Inbound SAML message issue instant not present in message context");
        }else{
            return;
        }
    }

    DateTime issueInstant = samlMsgCtx.getInboundSAMLMessageIssueInstant();
    DateTime now = new DateTime();
    DateTime latestValid = now.plusSeconds(clockSkew);
    DateTime expiration = issueInstant.plusSeconds(clockSkew + expires);

    // Check message wasn't issued in the future
    if (issueInstant.isAfter(latestValid)) {
        log.warn("Message was not yet valid: message time was {}, latest valid is: {}", issueInstant, latestValid);
        throw new SecurityPolicyException("Message was rejected because was issued in the future");
    }

    // Check message has not expired
    if (expiration.isBefore(now)) {
        log.warn("Message was expired: message issue time was '" + issueInstant + "', message expired at: '"
                + expiration + "', current time: '" + now + "'");
        throw new SecurityPolicyException("Message was rejected due to issue instant expiration");
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:IssueInstantRule.java

示例10: isValid

import org.joda.time.DateTime; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean isValid() {
    if (null == validUntil) {
        return true;
    }
    
    DateTime now = new DateTime();
    return now.isBefore(validUntil);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:EntitiesDescriptorImpl.java

示例11: applyExamFilter

import org.joda.time.DateTime; //导入方法依赖的package包/类
private boolean applyExamFilter(Exam e, Optional<String> start, Optional<String> end) {
    Boolean result = e.getState().ordinal() > Exam.State.PUBLISHED.ordinal() && !e.getExamParticipations().isEmpty();
    DateTime created = e.getCreated();
    if (start.isPresent()) {
        DateTime startDate = DateTime.parse(start.get(), ISODateTimeFormat.dateTimeParser());
        result = result && startDate.isBefore(created);
    }
    if (end.isPresent()) {
        DateTime endDate = DateTime.parse(end.get(), ISODateTimeFormat.dateTimeParser()).plusDays(1);
        result = result && endDate.isAfter(created);
    }
    return result;
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:14,代码来源:ReportController.java

示例12: isValid

import org.joda.time.DateTime; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean isValid() {
    if (null == validUntil) {
        return true;
    }

    DateTime now = new DateTime();
    return now.isBefore(validUntil);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:EntityDescriptorImpl.java

示例13: removeOldTimeStats

import org.joda.time.DateTime; //导入方法依赖的package包/类
public void removeOldTimeStats() {
    DateTime removeToDate = DateTime.now().withTimeAtStartOfDay().minusWeeks(1);
    Iterator<TimeStats> iter = timeStatsList.iterator();
    while (iter.hasNext()) {
        DateTime dateTime = iter.next().getDateTime();
        if (dateTime.isBefore(removeToDate)) {
            iter.remove();
        } else {
            break;
        }
    }
}
 
开发者ID:Rai220,项目名称:Telephoto,代码行数:13,代码来源:Prefs.java

示例14: hasNoOverlap

import org.joda.time.DateTime; //导入方法依赖的package包/类
private static boolean hasNoOverlap(List<Interval> reserved, DateTime searchStart, DateTime searchEnd) {
    DateTime earliestStart = reserved.get(0).getStart();
    DateTime latestStop = reserved.get(reserved.size() - 1).getEnd();
    return !searchEnd.isAfter(earliestStart) || !searchStart.isBefore(latestStop);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:6,代码来源:DateTimeUtils.java

示例15: setAlarms

import org.joda.time.DateTime; //导入方法依赖的package包/类
public void setAlarms() {
    List<Reminder> reminders = db.getReminders();
    int activeRemindersCount = 0;

    // Set an alarm for each date
    for (int i = 0; i < reminders.size(); i++) {
        Reminder reminder = reminders.get(i);

        Intent intent = new Intent(context, GlucosioBroadcastReceiver.class);
        intent.putExtra("metric", reminder.getMetric());
        intent.putExtra("glucosio_reminder", true);
        intent.putExtra("reminder_label", reminder.getLabel());

        PendingIntent alarmIntent = PendingIntent.getBroadcast(context, (int) reminder.getId(), intent, 0);

        if (reminder.isActive()) {
            activeRemindersCount++;
            Calendar calNow = Calendar.getInstance();
            Calendar calAlarm = Calendar.getInstance();
            calAlarm.setTime(reminder.getAlarmTime());
            calAlarm.set(Calendar.SECOND, 0);

            DateTime now = new DateTime(calNow.getTime());
            DateTime reminderDate = new DateTime(calAlarm);

            if (reminderDate.isBefore(now)) {
                calAlarm.set(Calendar.DATE, calNow.get(Calendar.DATE));
                calAlarm.add(Calendar.DATE, 1);
            }

            Log.d("Glucosio", "Added reminder on " + calAlarm.get(Calendar.DAY_OF_MONTH) + " at " + calAlarm.get(Calendar.HOUR) + ":" + calAlarm.get(Calendar.MINUTE));

            alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calAlarm.getTimeInMillis(),
                    AlarmManager.INTERVAL_DAY, alarmIntent);
        } else {
            alarmMgr.cancel(alarmIntent);
        }
    }

    enableBootReceiver(activeRemindersCount > 0);
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:42,代码来源:GlucosioAlarmManager.java


注:本文中的org.joda.time.DateTime.isBefore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。