diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/generation/KeyRingBuilder.java b/pgpainless-core/src/main/java/org/pgpainless/key/generation/KeyRingBuilder.java index 893036b1..a5263391 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/generation/KeyRingBuilder.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/generation/KeyRingBuilder.java @@ -63,7 +63,7 @@ public class KeyRingBuilder implements KeyRingBuilderInterface { private final List subkeySpecs = new ArrayList<>(); private final Map 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) { diff --git a/pgpainless-core/src/test/java/investigations/TimeTest.java b/pgpainless-core/src/test/java/investigations/TimeTest.java new file mode 100644 index 00000000..0807b161 --- /dev/null +++ b/pgpainless-core/src/test/java/investigations/TimeTest.java @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2018 Paul Schaub +// +// 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); + } +}