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


Java ZonedDateTime.toEpochSecond方法代碼示例

本文整理匯總了Java中java.time.ZonedDateTime.toEpochSecond方法的典型用法代碼示例。如果您正苦於以下問題:Java ZonedDateTime.toEpochSecond方法的具體用法?Java ZonedDateTime.toEpochSecond怎麽用?Java ZonedDateTime.toEpochSecond使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.ZonedDateTime的用法示例。


在下文中一共展示了ZonedDateTime.toEpochSecond方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isCasAuthenticationOldForMaxAgeAuthorizationRequest

import java.time.ZonedDateTime; //導入方法依賴的package包/類
/**
 * Is cas authentication old for max age authorization request boolean.
 *
 * @param context            the context
 * @param authenticationDate the authentication date
 * @return true/false
 */
public boolean isCasAuthenticationOldForMaxAgeAuthorizationRequest(final WebContext context,
                                                                   final ZonedDateTime authenticationDate) {
    final Optional<Long> maxAge = getOidcMaxAgeFromAuthorizationRequest(context);
    if (maxAge.isPresent() && maxAge.get() > 0) {
        final long now = ZonedDateTime.now().toEpochSecond();
        final long authTime = authenticationDate.toEpochSecond();
        final long diffInSeconds = now - authTime;
        if (diffInSeconds > maxAge.get()) {
            LOGGER.info("Authentication is too old: [{}] and was created [{}] seconds ago.",
                    authTime, diffInSeconds);
            return true;
        }
    }
    return false;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:23,代碼來源:OidcAuthorizationRequestSupport.java

示例2: cleanupAuditData

import java.time.ZonedDateTime; //導入方法依賴的package包/類
protected void cleanupAuditData(final String auditApplicationName, final JobExecutionContext context)
{
    final AuditService auditService = JobUtilities.getJobDataValue(context, "auditService", AuditService.class);

    final String cutOffPeriodStr = JobUtilities.getJobDataValue(context, "cutOffPeriod", String.class);
    final String timezoneStr = JobUtilities.getJobDataValue(context, "timezone", String.class, false);

    final Period cutOffPeriod = Period.parse(cutOffPeriodStr);
    final ZoneId zone = ZoneId.of(timezoneStr != null ? timezoneStr : "Z");
    final ZonedDateTime now = LocalDateTime.now(ZoneId.of("Z")).atZone(zone);
    final ZonedDateTime cutOffDate = now.minus(cutOffPeriod);
    final long epochSecond = cutOffDate.toEpochSecond();

    LOGGER.debug("Clearing all audit entries of application {} until {}", auditApplicationName, cutOffDate);
    auditService.clearAudit(auditApplicationName, null, Long.valueOf(epochSecond));
}
 
開發者ID:Acosix,項目名稱:alfresco-audit,代碼行數:17,代碼來源:AuditApplicationCleanupJob.java

示例3: parseTest

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Test
public void parseTest() throws IOException{

    ObjectMapper mapper = new ObjectMapper();
    Instant now = Instant.ofEpochSecond(System.currentTimeMillis() / 1000);
    ZonedDateTime auth_time = ZonedDateTime.ofInstant(now, ZoneId.systemDefault());
    ZonedDateTime iat = ZonedDateTime.from(auth_time);
    ZonedDateTime exp = ZonedDateTime
      .ofInstant(now, ZoneId.systemDefault())
      .plusMinutes(30);
    ZonedDateTime nbf = exp.minusMinutes(1);
    String jsonToken = "{\n" + "    \"exp\": " + exp.toEpochSecond() + ",\n" + "    \"nbf\": " + nbf.toEpochSecond() + ",\n" + "    \"ver\": \"1.0\",\n" + "    \"iss\": \"https://login.microsoftonline.com/11111111-1111-1111-1111-111111111111/v2.0/\",\n" + "    \"acr\": \"b2c_1_what-you-named-the-policy\",\n" + "    \"sub\": \"Not supported currently. Use oid claim.\",\n" + "    \"aud\": \"11111111-1111-1111-1111-111111111111\",\n" + "    \"nonce\": \"11111111-1111-1111-1111-111111111111\",\n" + "    \"iat\": " + iat.toEpochSecond() + ",\n" + "    \"auth_time\": " + auth_time.toEpochSecond() + ",\n" + "    \"oid\": \"11111111-1111-1111-1111-111111111111\",\n" + "    \"given_name\": \"One Punch\",\n" + "    \"family_name\": \"Saitama\",\n" + "    \"emails\": [\n" + "       \"[email protected]\"\n" + "    ]\n" + "}";

    BlueWebToken token = mapper.readValue(jsonToken, BlueWebToken.class);
    assertEquals(token.getExpiration(), exp);
    assertEquals(token.getNotBefore(), nbf);
    assertEquals(token.getVersion(), "1.0");
    assertEquals(token.getIssuer(), "https://login.microsoftonline.com/11111111-1111-1111-1111-111111111111/v2.0/");
    assertEquals(token.getAuthContextReference(), "b2c_1_what-you-named-the-policy");
    assertEquals(token.getSubject(), "Not supported currently. Use oid claim.");
    assertEquals(token.getAudience(), "11111111-1111-1111-1111-111111111111");
    assertEquals(token.getNonce(), "11111111-1111-1111-1111-111111111111");
    assertEquals(token.getIssuedAt(), iat);
    assertEquals(token.getAuthTime(), auth_time);
    assertEquals(token.getObjectId(), "11111111-1111-1111-1111-111111111111");
    assertEquals(token.getFirstName(), "One Punch");
    assertEquals(token.getLastName(), "Saitama");
    assertEquals(token.getFirstEmail(), "[email protected]");
}
 
開發者ID:Xitikit,項目名稱:xitikit-blue,代碼行數:30,代碼來源:BlueWebTokenTest.java

示例4: HackNews

import java.time.ZonedDateTime; //導入方法依賴的package包/類
public HackNews(ZonedDateTime now, double gravity) {
    this.now = now.toEpochSecond();
    this.gravity = gravity;
}
 
開發者ID:ugouku,項目名稱:shoucang,代碼行數:5,代碼來源:HackNews.java

示例5: age

import java.time.ZonedDateTime; //導入方法依賴的package包/類
private static long age(ZonedDateTime date) {
    return date.toEpochSecond() - BASE_TIME;
}
 
開發者ID:ugouku,項目名稱:shoucang,代碼行數:4,代碼來源:Reddit.java

示例6: getItems

import java.time.ZonedDateTime; //導入方法依賴的package包/類
@Override
public List<ITEM> getItems(ZonedDateTime startDate, ZonedDateTime endDate) {

    final long startRange = startDate.toEpochSecond();
    final long endRange = endDate.toEpochSecond();

    return itemList.parallelStream().filter(i -> {

        long itemStart = i.getStart().toEpochSecond();
        long itemEnd = i.getEnd().toEpochSecond();

        // Select only items that overlaps with startDate and endDate.

        return ((itemStart >= startRange && itemStart <= endRange)
                || (itemEnd >= startRange && itemEnd <= endRange)
                || (itemStart <= startRange && itemEnd >= endRange));

    }).collect(Collectors.toList());
}
 
開發者ID:blackbluegl,項目名稱:calendar-component,代碼行數:20,代碼來源:BasicItemProvider.java


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