1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-18 02:12:06 +01:00

Replace new Date().getTime() with System.getCurrentTimeMillis()

This commit is contained in:
Paul Schaub 2023-06-02 00:01:34 +02:00
parent 528591f906
commit d25e7419c9
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 27 additions and 1 deletions

View file

@ -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) {

View 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);
}
}