org.mockserver.time.TimeService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-core Show documentation
Show all versions of mockserver-core Show documentation
Functionality used by all MockServer modules for matching and expectations
package org.mockserver.time;
import java.time.Clock;
import java.time.Instant;
import java.time.OffsetDateTime;
public class TimeService {
public static final Instant FIXED_INSTANT_FOR_TESTS = Instant.now();
public static boolean fixedTime = false;
public static Instant now() {
if (!fixedTime) {
return Instant.now();
} else {
return FIXED_INSTANT_FOR_TESTS;
}
}
public static OffsetDateTime offsetNow() {
Instant now = TimeService.now();
return OffsetDateTime.ofInstant(now, Clock.systemDefaultZone().getZone().getRules().getOffset(now));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy