From 61eb2b3666344dac4247eed0c9405ef1c34b72ed Mon Sep 17 00:00:00 2001 From: Mikhail Puzanov Date: Thu, 30 Nov 2023 09:53:18 +0100 Subject: [PATCH] Simplify singleton implementation --- src/main/java/net/ripe/rpki/ta/util/ValidityPeriods.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/ripe/rpki/ta/util/ValidityPeriods.java b/src/main/java/net/ripe/rpki/ta/util/ValidityPeriods.java index b1d8011..fafddee 100644 --- a/src/main/java/net/ripe/rpki/ta/util/ValidityPeriods.java +++ b/src/main/java/net/ripe/rpki/ta/util/ValidityPeriods.java @@ -9,14 +9,11 @@ public class ValidityPeriods { private static final int TA_CERTIFICATE_VALIDITY_TIME_IN_YEARS = 100; - static DateTime globalNow; - // Since this program runs within a script, we can safely assume that all // calls to "now" can be replaced with a value calculated only once. - public static synchronized DateTime now() { - if (globalNow == null) { - globalNow = DateTime.now(DateTimeZone.UTC); - } + private static final DateTime globalNow = DateTime.now(DateTimeZone.UTC); + + public static DateTime now() { return globalNow; }