Replace more occurrences of new Date().getTime() with System.currentTimeMillis()

This commit is contained in:
Paul Schaub 2023-06-02 00:03:55 +02:00
parent d25e7419c9
commit e1038a8bb3
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
2 changed files with 9 additions and 9 deletions

View File

@ -155,7 +155,7 @@ public class ChangeExpirationOnKeyWithDifferentSignatureTypesTest {
private void executeTestForKeys(PGPSecretKeyRing keys, SecretKeyRingProtector protector)
throws PGPException {
Date expirationDate = new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 14);
Date expirationDate = new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24 * 14);
// round date for test stability
expirationDate = DateUtil.toSecondsPrecision(expirationDate);

View File

@ -59,8 +59,8 @@ public class DetachedSignTest {
List<Verification> verifications = sop.verify()
.cert(cert)
.notAfter(new Date(new Date().getTime() + 10000))
.notBefore(new Date(new Date().getTime() - 10000))
.notAfter(new Date(System.currentTimeMillis() + 10000))
.notBefore(new Date(System.currentTimeMillis() - 10000))
.signatures(signature)
.data(data);
@ -81,8 +81,8 @@ public class DetachedSignTest {
List<Verification> verifications = sop.verify()
.cert(cert)
.notAfter(new Date(new Date().getTime() + 10000))
.notBefore(new Date(new Date().getTime() - 10000))
.notAfter(new Date(System.currentTimeMillis() + 10000))
.notBefore(new Date(System.currentTimeMillis() - 10000))
.signatures(signature)
.data(data);
@ -101,8 +101,8 @@ public class DetachedSignTest {
List<Verification> verifications = sop.verify()
.cert(cert)
.notAfter(new Date(new Date().getTime() + 10000))
.notBefore(new Date(new Date().getTime() - 10000))
.notAfter(new Date(System.currentTimeMillis() + 10000))
.notBefore(new Date(System.currentTimeMillis() - 10000))
.signatures(signature)
.data(data);
@ -120,7 +120,7 @@ public class DetachedSignTest {
assertThrows(SOPGPException.NoSignature.class, () -> sop.verify()
.cert(cert)
.notAfter(new Date(new Date().getTime() - 10000)) // Sig is older
.notAfter(new Date(System.currentTimeMillis() - 10000)) // Sig is older
.signatures(signature)
.data(data));
}
@ -134,7 +134,7 @@ public class DetachedSignTest {
assertThrows(SOPGPException.NoSignature.class, () -> sop.verify()
.cert(cert)
.notBefore(new Date(new Date().getTime() + 10000)) // Sig is younger
.notBefore(new Date(System.currentTimeMillis() + 10000)) // Sig is younger
.signatures(signature)
.data(data));
}