diff --git a/spring-context/src/main/java/org/springframework/context/ApplicationEvent.java b/spring-context/src/main/java/org/springframework/context/ApplicationEvent.java index f54d7b91c8..fc059249a9 100644 --- a/spring-context/src/main/java/org/springframework/context/ApplicationEvent.java +++ b/spring-context/src/main/java/org/springframework/context/ApplicationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,9 +38,11 @@ public abstract class ApplicationEvent extends EventObject { /** - * Create a new {@code ApplicationEvent}. + * Create a new {@code ApplicationEvent} with its {@link #getTimestamp() timestamp} + * set to {@link System#currentTimeMillis()}. * @param source the object on which the event initially occurred or with * which the event is associated (never {@code null}) + * @see #ApplicationEvent(Object, Clock) */ public ApplicationEvent(Object source) { super(source); @@ -48,10 +50,14 @@ public abstract class ApplicationEvent extends EventObject { } /** - * Create a new {@code ApplicationEvent} with a fixed timestamp. + * Create a new {@code ApplicationEvent} with its {@link #getTimestamp() timestamp} + * set to the value returned by {@link Clock#millis()} in the provided {@link Clock}. + *
This constructor is typically used in testing scenarios. * @param source the object on which the event initially occurred or with * which the event is associated (never {@code null}) * @param clock a clock which will provide the timestamp + * @since 5.3.8 + * @see #ApplicationEvent(Object) */ public ApplicationEvent(Object source, Clock clock) { super(source); @@ -60,7 +66,9 @@ public abstract class ApplicationEvent extends EventObject { /** - * Return the system time in milliseconds when the event occurred. + * Return the time in milliseconds when the event occurred. + * @see #ApplicationEvent(Object) + * @see #ApplicationEvent(Object, Clock) */ public final long getTimestamp() { return this.timestamp;