本文整理匯總了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;
}
示例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);
}
}