本文整理汇总了Java中org.joda.time.DateTime.plusSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.plusSeconds方法的具体用法?Java DateTime.plusSeconds怎么用?Java DateTime.plusSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.plusSeconds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
}
示例2: overlaps
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* start | end | overlaps?
* ---------+--------+--------------------------------------------------
* now | now | check inavailability at both stations
* now | future | check inavailability at start station, be optimistic about end station
* future | now | false. cannot happen, chronologically not possible
* future | future | false. both in future => be optimistic, no check
*/
@Override
public boolean overlaps(int stayTime, RouteLegList legs,
SharingStation startStation, RouteLegWrapper bikeWrapper,
SharingStation endStation, RouteLegWrapper walkWrapper) {
// We always set stay time. Depending on DurationCheckStrategy it will be used or not.
walkWrapper.setStayTime(stayTime);
// -------------------------------------------------------------------------
// 1) If in future, be optimistic and assume always available
// -------------------------------------------------------------------------
Interval nowTimeWindow = getNowTimeWindow();
DateTime timeAtStartStation = legs.getAfterLastLeg();
boolean startIsNow = nowTimeWindow.contains(timeAtStartStation);
if (!startIsNow) {
return false;
}
// -------------------------------------------------------------------------
// 2) Check actual intervals for availability
// -------------------------------------------------------------------------
int bikeLegDuration = bikeWrapper.getLeg().getDuration();
int durationAfterStartStation = bikeLegDuration + durationCheckStrategy.getDurationToCheck(walkWrapper);
DateTime timeAtReturnStation = timeAtStartStation.plusSeconds(durationAfterStartStation);
boolean endIsNow = nowTimeWindow.contains(timeAtReturnStation);
if (endIsNow) {
// Check bike availability for "HinFahrt" at start station and "RückFahrt" at end station
return overlapsAtStation(legs, startStation, bikeLegDuration)
|| overlapsAtStation(legs, endStation, durationAfterStartStation);
} else {
// Check bike availability for "HinFahrt" at start station
return overlapsAtStation(legs, startStation, bikeLegDuration);
}
}
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:49,代码来源:WithReturnBikeInavailabilityStrategy.java
示例3: testDeparture
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Test
public void testDeparture() {
DateTime t1 = new DateTime(2016, 5, 24, 11, 0, DateTimeZone.UTC);
RouteLegList routeLegList = new RouteLegList(t1, false);
WalkingLeg walkingLeg1 = new WalkingLeg(LegType.WalkingLeg, geoCoord, geoCoord, distance, 50, sr, "");
DateTime t2 = t1.plusSeconds(50);
routeLegList.addAndShift(new RouteLegWrapper(walkingLeg1));
System.out.println(routeLegList);
CarLeg carLeg = new CarLeg(LegType.CarLeg, geoCoord, geoCoord, distance, 280, sr, "");
DateTime t3 = t2.plusSeconds(280);
Interval interval = routeLegList.getIntervalAfterPossibleLeg(carLeg.getDuration());
System.out.println(interval);
Assert.assertEquals(interval, new Interval(t2, t3));
routeLegList.addAndShift(new RouteLegWrapper(carLeg));
System.out.println(routeLegList);
WalkingLeg walkingLeg2 = new WalkingLeg(LegType.WalkingLeg, geoCoord, geoCoord, distance, 90, sr, "");
DateTime t4 = t3.plusSeconds(90);
Interval interval2 = routeLegList.getIntervalAfterPossibleLeg(walkingLeg2.getDuration());
System.out.println(interval2);
Assert.assertEquals(interval2, new Interval(t3, t4));
routeLegList.addAndShift(new RouteLegWrapper(walkingLeg2));
System.out.println(routeLegList);
}