// Path: src/main/java/de/galan/commons/time/ApplicationClock.java
// public class ApplicationClock {
// 
// 	public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
// 	private static Clock clock = Clock.systemUTC();
// 
// 
// 	/** Returns the configured application Clock instance. */
// 	public static Clock getClock() {
// 		return clock;
// 	}
// 
// 
// 	/** Sets the application clock. This should be done only at startup (usually not necessary), or in unit tests. */
// 	public static void setClock(Clock clock) {
// 		ApplicationClock.clock = clock;
// 	}
// 
// 
// 	/** Resets the application clock to the default. */
// 	public static void reset() {
// 		clock = Clock.systemUTC();
// 	}
// 
// 
// 	/** Creates a fixed Clock. */
// 	public static void setIso(Instant time) {
// 		setClock(Clock.fixed(time, ZoneId.of("UTC")));
// 	}
// 
// 
// 	/** Creates a fixed Clock. */
// 	public static void setUtc(Date time) {
// 		setClock(Clock.fixed(time.toInstant(), ZoneId.of("UTC")));
// 	}
// 
// 
// 	/** Creates a fixed Clock with the input format "yyyy-MM-dd'T'HH:mm:ss'Z'" using UTC as timezone. */
// 	public static void setUtc(String time) {
// 		Instant instant = Instant.parse(time);
// 		setClock(Clock.fixed(instant, ZoneId.of("UTC")));
// 	}
// 
// 
// 	/** Creates a fixed Clock with the input format "yyyy-MM-dd HH:mm:ss" using the local (systemDefault) timezone. */
// 	public static void setLocal(String time) {
// 		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
// 		Date result = null;
// 		try {
// 			result = sdf.parse(time);
// 		}
// 		catch (ParseException pex) {
// 			throw new RuntimeException("Time is not parseable (" + time + ")", pex);
// 		}
// 		setClock(Clock.fixed(result.toInstant(), ZoneId.systemDefault()));
// 	}
// 
// }


import java.time.Clock;
import java.time.Instant;
import java.util.Date;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import de.galan.commons.time.ApplicationClock;
package de.galan.commons.test.jupiter;





/**
 * Resets the ApplicationClock after each test. A Builder can be used to initialize it for all tests.
 */
public class ApplicationClockExtension implements BeforeEachCallback, AfterEachCallback {

	private Clock clock;


	public static ApplicationClockExtensionBuilder builder() {
		return new ApplicationClockExtensionBuilder();
	}

	/** Builder */
	public static class ApplicationClockExtensionBuilder {

		/** Creates a fixed Clock. */
		public ApplicationClockExtensionBuilder clock(Clock clock) {
			ApplicationClock.setClock(clock);
			return this;
		}


		/** Creates a fixed Clock with the given Instant. */
		public ApplicationClockExtensionBuilder instant(Instant instant) {
			ApplicationClock.setIso(instant);
			return this;
		}


		/**
		 * Creates a fixed Clock with the input format "yyyy-MM-dd HH:mm:ss" using the local (systemDefault) timezone.
		 */
		public ApplicationClockExtensionBuilder local(String time) {
			ApplicationClock.setLocal(time);
// Path: src/main/java/de/galan/commons/time/ApplicationClock.java
// public class ApplicationClock {
// 
// 	public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
// 	private static Clock clock = Clock.systemUTC();
// 
// 
// 	/** Returns the configured application Clock instance. */
// 	public static Clock getClock() {
// 		return clock;
// 	}
// 
// 
// 	/** Sets the application clock. This should be done only at startup (usually not necessary), or in unit tests. */
// 	public static void setClock(Clock clock) {
// 		ApplicationClock.clock = clock;
// 	}
// 
// 
// 	/** Resets the application clock to the default. */
// 	public static void reset() {
// 		clock = Clock.systemUTC();
// 	}
// 
// 
// 	/** Creates a fixed Clock. */
// 	public static void setIso(Instant time) {
// 		setClock(Clock.fixed(time, ZoneId.of("UTC")));
// 	}
// 
// 
// 	/** Creates a fixed Clock. */
// 	public static void setUtc(Date time) {
// 		setClock(Clock.fixed(time.toInstant(), ZoneId.of("UTC")));
// 	}
// 
// 
// 	/** Creates a fixed Clock with the input format "yyyy-MM-dd'T'HH:mm:ss'Z'" using UTC as timezone. */
// 	public static void setUtc(String time) {
// 		Instant instant = Instant.parse(time);
// 		setClock(Clock.fixed(instant, ZoneId.of("UTC")));
// 	}
// 
// 
// 	/** Creates a fixed Clock with the input format "yyyy-MM-dd HH:mm:ss" using the local (systemDefault) timezone. */
// 	public static void setLocal(String time) {
// 		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
// 		Date result = null;
// 		try {
// 			result = sdf.parse(time);
// 		}
// 		catch (ParseException pex) {
// 			throw new RuntimeException("Time is not parseable (" + time + ")", pex);
// 		}
// 		setClock(Clock.fixed(result.toInstant(), ZoneId.systemDefault()));
// 	}
// 
// }


// Path: src/main/java/de/galan/commons/test/jupiter/ApplicationClockExtension.java
import java.time.Clock;
import java.time.Instant;
import java.util.Date;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import de.galan.commons.time.ApplicationClock;

package de.galan.commons.test.jupiter;





/**
 * Resets the ApplicationClock after each test. A Builder can be used to initialize it for all tests.
 */
public class ApplicationClockExtension implements BeforeEachCallback, AfterEachCallback {

	private Clock clock;


	public static ApplicationClockExtensionBuilder builder() {
		return new ApplicationClockExtensionBuilder();
	}

	/** Builder */
	public static class ApplicationClockExtensionBuilder {

		/** Creates a fixed Clock. */
		public ApplicationClockExtensionBuilder clock(Clock clock) {
			ApplicationClock.setClock(clock);
			return this;
		}


		/** Creates a fixed Clock with the given Instant. */
		public ApplicationClockExtensionBuilder instant(Instant instant) {
			ApplicationClock.setIso(instant);
			return this;
		}


		/**
		 * Creates a fixed Clock with the input format "yyyy-MM-dd HH:mm:ss" using the local (systemDefault) timezone.
		 */
		public ApplicationClockExtensionBuilder local(String time) {
			ApplicationClock.setLocal(time);
			return this;