当前位置: 首页>>代码示例>>Java>>正文


Java ZonedDateTime.minusHours方法代码示例

本文整理汇总了Java中java.time.ZonedDateTime.minusHours方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.minusHours方法的具体用法?Java ZonedDateTime.minusHours怎么用?Java ZonedDateTime.minusHours使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.ZonedDateTime的用法示例。


在下文中一共展示了ZonedDateTime.minusHours方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTestParameters

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Gets the unit test parameters.
 *
 * @return  Test parameter data.
 * @throws Exception if there is an exception getting the test parameters.
 */
@Parameters
public static Collection<Object[]> getTestParameters() throws Exception {
    final Collection<Object[]> params = new ArrayList<>();

    final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
    final ZonedDateTime twoHoursAgo = now.minusHours(2);
    final ZonedDateTime oneHourAgo = now.minusHours(1);
    final ZonedDateTime halfHourAgo = now.minusMinutes(30);
    final X500Principal issuer = new X500Principal("CN=CAS");

    // Test case #1
    // Expect expired for zero leniency on CRL expiring 1ms ago
    final ThresholdExpiredCRLRevocationPolicy zeroThreshold = new ThresholdExpiredCRLRevocationPolicy(0);
    params.add(new Object[] {
            zeroThreshold,
            new MockX509CRL(issuer, DateTimeUtils.dateOf(oneHourAgo), DateTimeUtils.dateOf(now.minusSeconds(1))),
            new ExpiredCRLException("CN=CAS", ZonedDateTime.now(ZoneOffset.UTC)),
    });

    // Test case #2
    // Expect expired for 1h leniency on CRL expired 1 hour 1ms ago
    final ThresholdExpiredCRLRevocationPolicy oneHourThreshold = new ThresholdExpiredCRLRevocationPolicy(3600);
    params.add(new Object[] {
            oneHourThreshold,
            new MockX509CRL(issuer, DateTimeUtils.dateOf(twoHoursAgo), DateTimeUtils.dateOf(oneHourAgo.minusSeconds(1))),
            new ExpiredCRLException("CN=CAS", ZonedDateTime.now(ZoneOffset.UTC)),
    });

    // Test case #3
    // Expect valid for 1h leniency on CRL expired 30m ago
    params.add(new Object[] {
            oneHourThreshold,
            new MockX509CRL(issuer, DateTimeUtils.dateOf(twoHoursAgo), DateTimeUtils.dateOf(halfHourAgo)),
            null,
    });

    return params;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:45,代码来源:ThresholdExpiredCRLRevocationPolicyTests.java

示例2: initialize

import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static void initialize(long size) {
    for (long i = 0; i < size; ++i) {
        PostMeta post = new PostMeta();
        post.id = i;
        post.ups = (int) (Math.random() * 10000);
        post.downs = (int) (Math.random() * 10000);
        ZonedDateTime date = ZonedDateTime.now();
        date = date.minusHours((int) (Math.random() * 24 * 30 * 6));
        date = date.minusSeconds((int) (Math.random() * 3600));
        post.createdAt = date;
        post.hot = (int) (Math.random() * 2000);

        posts.add(post);
    }
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:16,代码来源:HotTest.java


注:本文中的java.time.ZonedDateTime.minusHours方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。