当前位置: 首页>>代码示例>>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;未经允许,请勿转载。