11package dev .runabout ;
22
33import java .lang .reflect .Method ;
4+ import java .time .Instant ;
45import java .util .Objects ;
56import java .util .Optional ;
67import java .util .Set ;
1415 */
1516public class RunaboutServiceBuilder <T extends JsonObject > {
1617
18+ private boolean excludeSuper = false ;
1719 private Supplier <Method > callerSupplier ;
1820 private Set <Class <?>> callerClassBlacklist ;
1921 private RunaboutSerializer customSerializer ;
2022 private Consumer <Throwable > throwableConsumer ;
21- private boolean excludeSuper = false ;
23+ private Supplier < String > datetimeSupplier ;
2224
2325 private final Supplier <T > jsonFactory ;
2426
@@ -109,6 +111,20 @@ public RunaboutServiceBuilder<T> setExcludeSuper(boolean excludeSuper) {
109111 this .excludeSuper = excludeSuper ;
110112 return this ;
111113 }
114+
115+ /**
116+ * Sets the datetime supplier for the RunaboutService.
117+ * The supplier should return the current datetime UTC as an ISO-8601 formatted string.
118+ * By default, the supplier will return the current datetime using {@link Instant#now()}.
119+ *
120+ * @param datetimeSupplier The datetime supplier.
121+ * @return The RunaboutServiceBuilder.
122+ */
123+ public RunaboutServiceBuilder <T > setDatetimeSupplier (Supplier <String > datetimeSupplier ) {
124+ this .datetimeSupplier = datetimeSupplier ;
125+ return this ;
126+ }
127+
112128 /**
113129 * Builds the RunaboutService.
114130 *
@@ -130,8 +146,11 @@ public RunaboutService<T> build() {
130146 final Consumer <Throwable > throwableConsumerFinal = Optional .ofNullable (throwableConsumer )
131147 .orElse (RunaboutServiceBuilder ::defaultThrowableConsumer );
132148
149+ final Supplier <String > datetimeSupplier = Optional .ofNullable (this .datetimeSupplier )
150+ .orElseGet (() -> () -> Instant .now ().toString ());
151+
133152 return new RunaboutServiceImpl <>(excludeSuper , throwableConsumerFinal , callerSupplierFinal ,
134- customSerializerFinal , jsonFactory );
153+ customSerializerFinal , jsonFactory , datetimeSupplier );
135154 }
136155
137156 private static void defaultThrowableConsumer (Throwable t ) {
0 commit comments