org.springframework.context

## Class ApplicationEvent

- java.lang.Object
- - java.util.EventObject
  - - org.springframework.context.ApplicationEvent

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    AbstractSubProtocolEvent, ApplicationContextEvent, BrokerAvailabilityEvent, PayloadApplicationEvent, RequestHandledEvent, TestContextEvent

      public abstract class ApplicationEvent
      extends EventObject

  Class to be extended by all application events. Abstract as it doesn't make sense for generic events to be published directly.
  Author:
    Rod Johnson, Juergen Hoeller
  See Also:
    `ApplicationListener`, `EventListener`, Serialized Form

- - ### Field Summary

    - ### Fields inherited from class java.util.EventObject

      `source`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ApplicationEvent(Object source)` Create a new `ApplicationEvent` with its `timestamp` set to `System.currentTimeMillis()`.
    `ApplicationEvent(Object source, Clock clock)` Create a new `ApplicationEvent` with its `timestamp` set to the value returned by `Clock.millis()` in the provided `Clock`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getTimestamp()` Return the time in milliseconds when the event occurred.

    - ### Methods inherited from class java.util.EventObject

      `getSource, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ApplicationEvent

          public ApplicationEvent(Object source)

      Create a new `ApplicationEvent` with its `timestamp` set to `System.currentTimeMillis()`.
      Parameters:
        `source` - the object on which the event initially occurred or with which the event is associated (never `null`)
      See Also:
        `ApplicationEvent(Object, Clock)`

    - #### ApplicationEvent

          public ApplicationEvent(Object source,
                                  Clock clock)

      Create a new `ApplicationEvent` with its `timestamp` set to the value returned by `Clock.millis()` in the provided `Clock`.

      This constructor is typically used in testing scenarios.

      Parameters:
        `source` - the object on which the event initially occurred or with which the event is associated (never `null`)
        `clock` - a clock which will provide the timestamp
      Since:
        5.3.8
      See Also:
        `ApplicationEvent(Object)`

  - ### Method Detail

    - #### getTimestamp

          public final long getTimestamp()

      Return the time in milliseconds when the event occurred.
      See Also:
        `ApplicationEvent(Object)`, `ApplicationEvent(Object, Clock)`