diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java index e1a9cd2a09a8..1094ce8c04d4 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java @@ -16,10 +16,15 @@ */ package org.apache.logging.log4j.core.util; +import java.time.Instant; +import org.apache.logging.log4j.core.time.MutableInstant; +import org.apache.logging.log4j.core.time.PreciseClock; + /** * Implementation of the {@code Clock} interface that returns the system time. + * @since 2.25 */ -public final class SystemClock implements Clock { +public final class SystemClock implements Clock, PreciseClock { /** * Returns the system time. @@ -29,4 +34,13 @@ public final class SystemClock implements Clock { public long currentTimeMillis() { return System.currentTimeMillis(); } + + /** + * {@inheritDoc} + */ + @Override + public void init(final MutableInstant mutableInstant) { + final Instant instant = java.time.Clock.systemUTC().instant(); + mutableInstant.initFromEpochSecond(instant.getEpochSecond(), instant.getNano()); + } } diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/package-info.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/package-info.java index 06e847dcfefd..932e8bc0800c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/package-info.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/package-info.java @@ -18,7 +18,7 @@ * Log4j 2 helper classes. */ @Export -@Version("2.24.2") +@Version("2.25.0") package org.apache.logging.log4j.core.util; import org.osgi.annotation.bundle.Export;