當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTime.isBeforeNow方法代碼示例

本文整理匯總了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();
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:19,代碼來源:SessionController.java

示例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();
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:18,代碼來源:JournalAdapter.java

示例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();
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:18,代碼來源:JournalAdapter.java

示例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());
    }
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:32,代碼來源:ArchiveScheduledJob.java

示例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");
}
 
開發者ID:riteshakya037,項目名稱:Android-Scrapper,代碼行數:16,代碼來源:ScrapperService.java

示例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;
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:31,代碼來源:CalendarReservationSanitizer.java

示例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);
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:33,代碼來源:ExternalCalendarController.java

示例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();
}
 
開發者ID:Microsoft,項目名稱:healthvault-java-sdk,代碼行數:16,代碼來源:HealthVaultRestClient.java

示例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());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:53,代碼來源:AbstractReloadingMetadataProvider.java

示例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;
    }
}
 
開發者ID:UMM-CSci-3601-S17,項目名稱:digital-display-garden-iteration-4-dorfner-v2,代碼行數:62,代碼來源:Auth.java


注:本文中的org.joda.time.DateTime.isBeforeNow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。