本文整理汇总了Java中org.joda.time.DateTime.isBeforeNow方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.isBeforeNow方法的具体用法?Java DateTime.isBeforeNow怎么用?Java DateTime.isBeforeNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.isBeforeNow方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSession
import org.joda.time.DateTime; //导入方法依赖的package包/类
@ActionMethod
public Result checkSession() {
Session session = getSession();
if (session == null || session.getSince() == null) {
Logger.info("Session not found");
return ok("no_session");
}
DateTime expirationTime = session.getSince().plusMinutes(SITNET_TIMEOUT_MINUTES);
DateTime alarmTime = expirationTime.minusMinutes(2);
Logger.debug("Session expiration due at {}", expirationTime);
if (expirationTime.isBeforeNow()) {
Logger.info("Session has expired");
return ok("no_session");
} else if (alarmTime.isBeforeNow()) {
return ok("alarm");
}
return ok();
}
示例2: reloadFrom
import org.joda.time.DateTime; //导入方法依赖的package包/类
public void reloadFrom(final List<Trip> data) {
current.clear();
past.clear();
future.clear();
for (Trip t : data) {
DateTime begDate = DateTime.parse(t.startDate);
DateTime endDate = DateTime.parse(t.endDate);
if (begDate.isAfterNow()) {
future.add(t);
} else if (endDate.isBeforeNow()) {
past.add(t);
} else {
current.add(t);
}
}
notifyDataSetChanged();
}
示例3: reloadFrom
import org.joda.time.DateTime; //导入方法依赖的package包/类
public void reloadFrom(final List<Trip> data) {
current.clear();
past.clear();
future.clear();
for (Trip t : data) {
DateTime begDate = DateTime.parse(t.getStartDate());
DateTime endDate = DateTime.parse(t.getEndDate());
if (begDate.isAfterNow()) {
future.add(t);
} else if (endDate.isBeforeNow()) {
past.add(t);
} else {
current.add(t);
}
}
notifyDataSetChanged();
}
示例4: execute
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
GetJobsArchiveServiceApi jobsArchiveService = (GetJobsArchiveServiceApi) context.getMergedJobDataMap().get(GetJobsArchiveServiceApi.class.getName());
ArchiveServiceApi archiveService = (ArchiveServiceApi) context.getMergedJobDataMap().get(ArchiveServiceApi.class.getName());
try {
BaseDtoResponse<JobsArchiveDto> reponse = jobsArchiveService.dispatch(new Request() {
});
Period period = new Period();
if (FreqType.valueOf(reponse.getDto().getFrequency()) == FreqType.MONTHLY) {
period = Period.months(1);
} else {
period = Period.weeks(1);
}
DateTime futureJob = new DateTime(reponse.getDto().getLastTriggerTimestamp()).plus(period);
if (reponse.getDto().getLastTriggerTimestamp() == null || futureJob.isBeforeNow()) {
log.info("Archiving Job Trigggered at : " + new Date());
BaseRequest<JobsArchiveDto> request = new BaseRequest<JobsArchiveDto>();
request.setDto(new JobsArchiveDto());
request.getDto().setId(1L);
archiveService.dispatch(request);
}
} catch (Exception e) {
log.error("Failure during archive operation", e);
StaticRegistry.alertGenerator().processSystemFailureEvent(SystemFailureType.ARCHIVE_FAILURE,
new LockObjectReference(1L, "Archive Settings", ObjectType.ARCHIVE),
"Failure during archive operation " + e.getMessage());
}
}
示例5: reloadTimer
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* Change the time at which the games are to be fetched.
*/
private void reloadTimer() {
String updateTime = MultiProcessPreference.getDefaultSharedPreferences()
.getString(getString(R.string.key_bid_update_time), "0:0");
DateTime dateTime = new DateTime();
dateTime = dateTime.withTimeAtStartOfDay().plusHours(StringUtils.getHour(updateTime)).plusMinutes(StringUtils.getMinute(updateTime));
if (dateTime.isBeforeNow()) {
dateTime = dateTime.plusDays(1);
}
updateGames(new DateTime(dateTime.getMillis()).toDateTime(DateTimeZone.getDefault()).getMillis(), NORMAL_REPEAT);
Log.i(TAG, "Reloaded Timer");
}
示例6: 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;
}
示例7: provideReservation
import org.joda.time.DateTime; //导入方法依赖的package包/类
@SubjectNotPresent
public Result provideReservation() {
// Parse request body
JsonNode node = request().body().asJson();
String reservationRef = node.get("id").asText();
String roomRef = node.get("roomId").asText();
DateTime start = ISODateTimeFormat.dateTimeParser().parseDateTime(node.get("start").asText());
DateTime end = ISODateTimeFormat.dateTimeParser().parseDateTime(node.get("end").asText());
String userEppn = node.get("user").asText();
if (start.isBeforeNow() || end.isBefore(start)) {
return badRequest("invalid dates");
}
ExamRoom room = Ebean.find(ExamRoom.class).where().eq("externalRef", roomRef).findUnique();
if (room == null) {
return notFound("room not found");
}
Optional<ExamMachine> machine = getRandomMachine(room, null, start, end, Collections.emptyList());
if (!machine.isPresent()) {
return forbidden("sitnet_no_machines_available");
}
// We are good to go :)
Reservation reservation = new Reservation();
reservation.setExternalRef(reservationRef);
reservation.setEndAt(end);
reservation.setStartAt(start);
reservation.setMachine(machine.get());
reservation.setExternalUserRef(userEppn);
reservation.save();
PathProperties pp = PathProperties.parse("(*, machine(*, room(*, mailAddress(*))))");
return created(reservation, pp);
}
示例8: getAuthToken
import org.joda.time.DateTime; //导入方法依赖的package包/类
private String getAuthToken (Connection connection, Record currentRecord){
DateTime dateTime= mSettings.getSessionExpiration();
if(dateTime.isBeforeNow()) {
tokenRefresh(connection);
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("MSH-V1 app-token=");
stringBuilder.append(connection.getSessionToken().toString());
stringBuilder.append(",offline-person-id=");
stringBuilder.append(currentRecord.getPersonId());
stringBuilder.append(",record-id=");
stringBuilder.append(currentRecord.getId());
return stringBuilder.toString();
}
示例9: processNonExpiredMetadata
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* Processes metadata that has been determined to be valid at the time it was fetched. A metadata document is
* considered be valid if its root element returns true when passed to the {@link #isValid(XMLObject)} method.
*
* @param metadataIdentifier identifier of the metadata source
* @param refreshStart when the current refresh cycle started
* @param metadataBytes raw bytes of the new metadata document
* @param metadata new metadata document unmarshalled
*
* @throws MetadataProviderException thrown if there s a problem processing the metadata
*/
protected void processNonExpiredMetadata(String metadataIdentifier, DateTime refreshStart, byte[] metadataBytes,
XMLObject metadata) throws MetadataProviderException {
Document metadataDom = metadata.getDOM().getOwnerDocument();
log.debug("Filtering metadata from '{}'", metadataIdentifier);
try {
filterMetadata(metadata);
} catch (FilterException e) {
String errMsg = "Error filtering metadata from " + metadataIdentifier;
log.error(errMsg, e);
throw new MetadataProviderException(errMsg, e);
}
log.debug("Releasing cached DOM for metadata from '{}'", metadataIdentifier);
releaseMetadataDOM(metadata);
log.debug("Post-processing metadata from '{}'", metadataIdentifier);
postProcessMetadata(metadataBytes, metadataDom, metadata);
log.debug("Computing expiration time for metadata from '{}'", metadataIdentifier);
DateTime metadataExpirationTime =
SAML2Helper.getEarliestExpiration(metadata, refreshStart.plus(getMaxRefreshDelay()), refreshStart);
log.debug("Expiration of metadata from '{}' will occur at {}", metadataIdentifier,
metadataExpirationTime.toString());
cachedMetadata = metadata;
lastUpdate = refreshStart;
long nextRefreshDelay;
if (metadataExpirationTime.isBeforeNow()) {
expirationTime = new DateTime(ISOChronology.getInstanceUTC()).plus(getMinRefreshDelay());
nextRefreshDelay = getMaxRefreshDelay();
} else {
expirationTime = metadataExpirationTime;
nextRefreshDelay = computeNextRefreshDelay(expirationTime);
}
nextRefresh = new DateTime(ISOChronology.getInstanceUTC()).plus(nextRefreshDelay);
emitChangeEvent();
log.info("New metadata succesfully loaded for '{}'", getMetadataIdentifier());
}
示例10: verifyCallBack
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* Consumes the state and the code that Google gives to visitors, so
* that they can in turn give them to us. This method confirms that
* the state is one we issued and is non-expired. It then fetches
* tokens from Google, confirms the signature (even though Google
* says we don't need to work about it since we are fetching via
* HTTPS), and user's email from the token.
* @param state should be a JWT signed by us
* @param code should be a "code" (whatever that means) from Google
* @return a string with URL that the visitor was originally trying
* to load. Null if the state or code are invalid in any way
* or if we cannot contact Google to verify them.
*/
public String verifyCallBack(String state, String code) throws UnauthorizedUserException, ExpiredTokenException{
// parse the state and ensure its validity
RedirectToken verifiedState = unpackSharedGoogleSecret(state);
DateTime expTime = new DateTime(verifiedState.exp);
if(expTime.isBeforeNow()) {
// the user took too long to complete the authentication
throw new ExpiredTokenException("The DDG token is expired");
}
try {
// Use the callback code to get a token from Google with info
// about the caller
OAuth2AccessToken accessToken = globalService.getAccessToken(code);
accessToken = globalService.refreshAccessToken(accessToken.getRefreshToken());
// parse the token for the fields we want
GoogleToken googleToken = gson.fromJson(accessToken.getRawResponse(), GoogleToken.class);
// Get the URL for Google's OpenID description
OpenIDConfiguration openIDConfiguration = getOpenIDConfiguration();
// Confirm that the token is signed properly and extract the body as JSON
String stringBody = parseAndValidate(googleToken.id_token, new URL(openIDConfiguration.jwks_uri));
// Parse the JSON for the fields we care about
GoogleJwtBody body = gson.fromJson(stringBody, GoogleJwtBody.class);
// Confirm that the token is not expired
if (new DateTime(body.exp * 1000).isBeforeNow()) {
// Google is sending us bad tokens!!!
return null;
}
// Confirm that the user is on our whitelist
boolean authorized = userIsAuthorized(body.email);
if (authorized) {
return verifiedState.originatingURL;
} else {
throw new UnauthorizedUserException();
}
} catch (IOException|InterruptedException|ExecutionException e) {
// these just generally mean that something went wrong
// with interacting with Google's API
e.printStackTrace();
return null;
}
}