mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-17 18:02:05 +01:00
Replace new Date().getTime() with System.getCurrentTimeMillis()
This commit is contained in:
parent
528591f906
commit
d25e7419c9
2 changed files with 27 additions and 1 deletions
|
@ -63,7 +63,7 @@ public class KeyRingBuilder implements KeyRingBuilderInterface<KeyRingBuilder> {
|
|||
private final List<KeySpec> subkeySpecs = new ArrayList<>();
|
||||
private final Map<String, SelfSignatureSubpackets.Callback> userIds = new LinkedHashMap<>();
|
||||
private Passphrase passphrase = Passphrase.emptyPassphrase();
|
||||
private Date expirationDate = new Date(new Date().getTime() + YEAR_IN_SECONDS * 5); // Expiration in 5 yeras
|
||||
private Date expirationDate = new Date(System.currentTimeMillis() + YEAR_IN_SECONDS * 5); // Expiration in 5 yeras
|
||||
|
||||
@Override
|
||||
public KeyRingBuilder setPrimaryKey(@Nonnull KeySpec keySpec) {
|
||||
|
|
26
pgpainless-core/src/test/java/investigations/TimeTest.java
Normal file
26
pgpainless-core/src/test/java/investigations/TimeTest.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package investigations;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.JUtils.assertEquals;
|
||||
|
||||
/**
|
||||
* Exploratory test for date and time related operations.
|
||||
*/
|
||||
public class TimeTest {
|
||||
|
||||
@Test
|
||||
public void newDateGetTimeEqualsSystemCurrentTimeMillis() {
|
||||
Date date = new Date();
|
||||
long dateTime = date.getTime();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
assertEquals(dateTime, currentTime, 10);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue