本文整理汇总了Java中org.joda.time.DateTime.isAfter方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.isAfter方法的具体用法?Java DateTime.isAfter怎么用?Java DateTime.isAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.isAfter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchMetadata
import org.joda.time.DateTime; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected byte[] fetchMetadata() throws ResolverException {
try {
ResolverHelper.validateMetadataFile(metadataFile);
DateTime metadataUpdateTime = getMetadataUpdateTime();
if (getLastRefresh() == null || getLastUpdate() == null || metadataUpdateTime.isAfter(getLastRefresh())) {
log.debug("Returning the contents of {} as byte array", metadataFile.toPath());
return ResolverHelper.inputstreamToByteArray(new FileInputStream(metadataFile));
}
return null;
} catch (IOException e) {
String errMsg = "Unable to read metadata file " + metadataFile.getAbsolutePath();
log.error(errMsg, e);
throw new ResolverException(errMsg, e);
}
}
示例2: isServiceAccessAllowed
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public boolean isServiceAccessAllowed() {
final DateTime now = DateTime.now();
if (this.startingDateTime != null) {
final DateTime st = DateTime.parse(this.startingDateTime);
if (now.isBefore(st)) {
LOGGER.warn("Service access not allowed because it starts at {}. Now is {}",
this.startingDateTime, now);
return false;
}
}
if (this.endingDateTime != null) {
final DateTime et = DateTime.parse(this.endingDateTime);
if (now.isAfter(et)) {
LOGGER.warn("Service access not allowed because it ended at {}. Now is {}",
this.endingDateTime, now);
return false;
}
}
return super.isServiceAccessAllowed();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:26,代码来源:TimeBasedRegisteredServiceAccessStrategy.java
示例3: removeResources
import org.joda.time.DateTime; //导入方法依赖的package包/类
public void removeResources(PodResource pod, DeploymentResource deployment, String cluster, String namespace,
String name) {
if (pod.getStatus().getContainerStatuses() != null && pod.getStatus().getContainerStatuses()[0]
.getState().getWaiting() != null && deployment.getMetadata().getLabels()
.get(crashLoopDetectionTimeLiteral) != null) {
DateTime currentTime = new DateTime();
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH.mm.ss'Z'");
DateTime timeCutoff = currentTime.minusWeeks(kubernetesConfig.getNumWeeks());
DateTime crashLoopTime = format.parseDateTime(deployment.getMetadata().getLabels()
.get(crashLoopDetectionTimeLiteral)).toDateTime();
if (timeCutoff.isAfter(crashLoopTime)) {
deploymentResourceService.deleteDeploymentResource(cluster, namespace, name);
replicasetResourceService.deleteReplicasetResource(cluster, namespace, name);
podResourceService.deletePodResource(cluster, namespace, name);
serviceResourceService.deleteService(cluster, namespace, name);
ingressResourceService.deleteIngressResource(cluster, namespace, name);
autoscalerResourceService.deleteAutoscaler(cluster, namespace, name);
hipchatService.notifyDelete(cluster, namespace, name);
}
}
}
示例4: isValidWorkingPeriod
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public boolean isValidWorkingPeriod(DateTime workingStart, DateTime workingEnd) {
if(workingStart.isAfter(workingEnd)) {
return false;
} else {
return workingStart.getMinuteOfDay() >= 15 && workingEnd.getMinuteOfDay() <= 1425;
}
}
示例5: isServiceAccessAllowed
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public boolean isServiceAccessAllowed() {
final DateTime now = DateTime.now();
if (this.startingDateTime != null) {
final DateTime st = DateTime.parse(this.startingDateTime);
if (now.isBefore(st)) {
logger.warn("Service access not allowed because it starts at {}. Now is {}",
this.startingDateTime, now);
return false;
}
}
if (this.endingDateTime != null) {
final DateTime et = DateTime.parse(this.endingDateTime);
if (now.isAfter(et)) {
logger.warn("Service access not allowed because it ended at {}. Now is {}",
this.endingDateTime, now);
return false;
}
}
return super.isServiceAccessAllowed();
}
示例6: getTimeStatsList
import org.joda.time.DateTime; //导入方法依赖的package包/类
public List<TimeStats> getTimeStatsList(DateTime from, DateTime to) {
List<TimeStats> result = new LinkedList<>();
if (!from.isAfter(to)) {
int fromIndex = -1;
int toIndex = -1;
sortTimeStatsList(timeStatsList);
for (TimeStats stat : timeStatsList) {
if (fromIndex == -1 && !from.isAfter(stat.getDateTime())) {
fromIndex = timeStatsList.indexOf(stat);
} else if (stat.getDateTime().isAfter(to)) {
toIndex = timeStatsList.indexOf(stat);
break;
}
}
if (fromIndex != -1) {
if (toIndex == -1 || toIndex > timeStatsList.size()) {
toIndex = timeStatsList.size();
}
result = timeStatsList.subList(fromIndex, toIndex);
}
}
return result;
}
示例7: fetchMetadata
import org.joda.time.DateTime; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected byte[] fetchMetadata() throws MetadataProviderException {
try {
validateMetadataFile(metadataFile);
DateTime metadataUpdateTime = new DateTime(metadataFile.lastModified(), ISOChronology.getInstanceUTC());
if (getLastRefresh() == null || getLastUpdate() == null || metadataUpdateTime.isAfter(getLastRefresh())) {
return inputstreamToByteArray(new FileInputStream(metadataFile));
}
return null;
} catch (IOException e) {
String errMsg = "Unable to read metadata file " + metadataFile.getAbsolutePath();
log.error(errMsg, e);
throw new MetadataProviderException(errMsg, e);
}
}
示例8: dateBetweenSearch
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Test
public void dateBetweenSearch() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
DateTimeFormatter formatter = DateTimeFormat.forPattern(DATE_FORMAT);
DateTime dateLimit1 = new DateTime(2014, 8, 18, 0, 0, 0);
DateTime dateLimit2 = new DateTime(2014, 8, 21, 0, 0, 0);
SearchHits response = query(String.format("SELECT insert_time FROM %s/online WHERE insert_time BETWEEN '2014-08-18' AND '2014-08-21' LIMIT 3", TEST_INDEX));
SearchHit[] hits = response.getHits();
for(SearchHit hit : hits) {
Map<String, Object> source = hit.getSource();
DateTime insertTime = formatter.parseDateTime((String) source.get("insert_time"));
boolean isBetween =
(insertTime.isAfter(dateLimit1) || insertTime.isEqual(dateLimit1)) &&
(insertTime.isBefore(dateLimit2) || insertTime.isEqual(dateLimit2));
Assert.assertTrue("insert_time must be between 2014-08-18 and 2014-08-21", isBetween);
}
}
示例9: isWinterTime
import org.joda.time.DateTime; //导入方法依赖的package包/类
public static boolean isWinterTime() {
DateTime currentDate = new DateTime();
DateTime firstNovemberSunday = currentDate.withMonthOfYear(1).withDayOfYear(1).withMonthOfYear(11).withDayOfWeek(7);
DateTime secondMarchSunday = currentDate.withMonthOfYear(1).withDayOfYear(1).withMonthOfYear(3).withDayOfWeek(7).plusWeeks(1);
int currentMonth = currentDate.monthOfYear().get();
return (currentMonth == 12 || currentMonth == 1 || currentMonth == 2) ||
(currentMonth == 3 && currentDate.isBefore(secondMarchSunday)) ||
(currentMonth == 11 && currentDate.isAfter(firstNovemberSunday));
}
示例10: checkExpiryDate
import org.joda.time.DateTime; //导入方法依赖的package包/类
private void checkExpiryDate(Date expiryDate)
{
DateTime now = DateTime.now();
if (now.isAfter(expiryDate.getTime()))
{
throw new QuickShareLinkExpiryActionException.InvalidExpiryDateException("Invalid expiry date. Expiry date can't be in the past.");
}
if (expiryDatePeriod.getDuration(now, new DateTime(expiryDate)) < 1)
{
throw new QuickShareLinkExpiryActionException.InvalidExpiryDateException(
"Invalid expiry date. Expiry date can't be less then 1 " + expiryDatePeriod.getMessage() + '.');
}
}
示例11: haveEntitiesChanged
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* This method checks to see if any objects related to the policy evaluation have been changed since the Policy
* Evaluation Result was cached.
*
* @param values List of values which contain subject, policy sets and resolved resource URI's.
* @param policyEvalTimestampUTC The timestamp to compare against.
* @return true or false depending on whether any of the objects in values has a timestamp after
* policyEvalTimestampUTC.
*/
boolean haveEntitiesChanged(final List<String> values, final DateTime policyEvalTimestampUTC) {
for (String value : values) {
if (null == value) {
return true;
}
DateTime invalidationTimestampUTC = timestampToDateUTC(value);
if (invalidationTimestampUTC.isAfter(policyEvalTimestampUTC)) {
LOGGER.debug("Privilege service attributes have timestamp '{}' which is after "
+ "policy evaluation timestamp '{}'", invalidationTimestampUTC, policyEvalTimestampUTC);
return true;
}
}
return false;
}
示例12: createDefaultStartingHours
import org.joda.time.DateTime; //导入方法依赖的package包/类
private static List<ExamStartingHour> createDefaultStartingHours(String roomTz) {
// Get offset from Jan 1st in order to no have DST in effect
DateTimeZone zone = DateTimeZone.forID(roomTz);
DateTime beginning = DateTime.now().withDayOfYear(1).withTimeAtStartOfDay();
DateTime ending = beginning.plusHours(LAST_HOUR);
List<ExamStartingHour> hours = new ArrayList<>();
while (!beginning.isAfter(ending)) {
ExamStartingHour esh = new ExamStartingHour();
esh.setStartingHour(beginning.toDate());
esh.setTimezoneOffset(zone.getOffset(beginning));
hours.add(esh);
beginning = beginning.plusHours(1);
}
return hours;
}
示例13: 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;
}
示例14: executeTokenPreflight
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* Update the persisted access token and the authorization header if necessary
*
* @return The current access token
*/
@SuppressWarnings("Duplicates")
private synchronized Map<String, Object> executeTokenPreflight() throws Exception {
AuthToken token = authTokenDao.get(TokenGroup.INTEGRATIONS, "streamlabs");
if (StringUtils.isEmpty(token.getToken())) {
throw new UnavailableException("The Stream Labs is not connected to an account");
}
DateTime expiryTime = token.getExpiryTime();
DateTime now = DateTime.now();
if (expiryTime != null && now.isAfter(expiryTime)) {
StreamLabsOAuthDirector director = new StreamLabsOAuthDirector(configService.getConsumerKey(), configService.getConsumerSecret(), webClient);
boolean refreshSuccess = director.awaitRefreshedAccessToken(token.getRefreshToken());
if (refreshSuccess) {
token.setToken(director.getAccessToken());
token.setRefreshToken(director.getRefreshToken());
token.setTimeToLive(director.getTimeToLive());
token.setIssuedAt(now);
authTokenDao.save(token);
} else {
throw new UnavailableException("The Stream Labs Api failed to refresh the access token: " + director.getAuthenticationError());
}
}
return ModelUtils.mapWith(new ModelUtils.MapEntry<>("access_token", token.getToken()));
}
示例15: allSlots
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* @return all intervals that fall within provided working hours
*/
private static Iterable<Interval> allSlots(Iterable<ExamRoom.OpeningHours> openingHours, ExamRoom room, LocalDate date) {
Collection<Interval> intervals = new ArrayList<>();
List<ExamStartingHour> startingHours = room.getExamStartingHours();
if (startingHours.isEmpty()) {
// Default to 1 hour slots that start at the hour
startingHours = createDefaultStartingHours(room.getLocalTimezone());
}
Collections.sort(startingHours);
DateTime now = DateTime.now().plusMillis(DateTimeZone.forID(room.getLocalTimezone()).getOffset(DateTime.now()));
for (ExamRoom.OpeningHours oh : openingHours) {
int tzOffset = oh.getTimezoneOffset();
DateTime instant = now.getDayOfYear() == date.getDayOfYear() ? now : oh.getHours().getStart();
DateTime slotEnd = oh.getHours().getEnd();
DateTime beginning = nextStartingTime(instant, startingHours, tzOffset);
while (beginning != null) {
DateTime nextBeginning = nextStartingTime(beginning.plusMillis(1), startingHours, tzOffset);
if (beginning.isBefore(oh.getHours().getStart())) {
beginning = nextBeginning;
continue;
}
if (nextBeginning != null && !nextBeginning.isAfter(slotEnd)) {
intervals.add(new Interval(beginning.minusMillis(tzOffset), nextBeginning.minusMillis(tzOffset)));
beginning = nextBeginning;
} else if (beginning.isBefore(slotEnd)) {
// We have some spare time in the end, take it as well
intervals.add(new Interval(beginning.minusMillis(tzOffset), slotEnd.minusMillis(tzOffset)));
break;
} else {
break;
}
}
}
return intervals;
}