Skip to content

Commit

Permalink
Simplify singleton implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lolepezy committed Nov 30, 2023
1 parent 07d8e61 commit 61eb2b3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main/java/net/ripe/rpki/ta/util/ValidityPeriods.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 61eb2b3

Please sign in to comment.