org.apache.commons.io.input

## Class TimestampedObserver

- java.lang.Object
- - org.apache.commons.io.input.ObservableInputStream.Observer
  - - org.apache.commons.io.input.TimestampedObserver

-     public class TimestampedObserver
      extends ObservableInputStream.Observer

  An observer with timestamps.

  For example:

       final TimestampedObserver timestampedObserver = new TimestampedObserver();
       try (ObservableInputStream inputStream = new ObservableInputStream(...),
           timestampedObserver)) {
           ...
       }
       System.out.printf("IO duration: %s%n", timestampedObserver.getOpenToCloseDuration());

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimestampedObserver()` Constructs a new instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closed()` Called to indicate that the `ObservableInputStream` has been closed.
    `java.time.Instant` | `getCloseInstant()` Gets the instant for when this instance was closed.
    `java.time.Instant` | `getOpenInstant()` Gets the instant for when this instance was created.
    `java.time.Duration` | `getOpenToCloseDuration()` Gets the Duration between creation and close.
    `java.time.Duration` | `getOpenToNowDuration()` Gets the Duration between creation and now.
    `boolean` | `isClosed()` Tests whether `closed()` has been called.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.commons.io.input.ObservableInputStream.Observer

      `data, data, error, finished`

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

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

- - ### Constructor Detail

    - #### TimestampedObserver

          public TimestampedObserver()

      Constructs a new instance.

  - ### Method Detail

    - #### closed

          public void closed()
                      throws IOException

      Description copied from class: `ObservableInputStream.Observer`
      Called to indicate that the `ObservableInputStream` has been closed.
      Overrides:
        `closed` in class `ObservableInputStream.Observer`
      Throws:
        `IOException` - if an I/O error occurs.

    - #### getCloseInstant

          public java.time.Instant getCloseInstant()

      Gets the instant for when this instance was closed.
      Returns:
        the instant for when closed was called.

    - #### getOpenInstant

          public java.time.Instant getOpenInstant()

      Gets the instant for when this instance was created.
      Returns:
        the instant for when this instance was created.

    - #### getOpenToCloseDuration

          public java.time.Duration getOpenToCloseDuration()

      Gets the Duration between creation and close.
      Returns:
        the Duration between creation and close.

    - #### getOpenToNowDuration

          public java.time.Duration getOpenToNowDuration()

      Gets the Duration between creation and now.
      Returns:
        the Duration between creation and now.

    - #### isClosed

          public boolean isClosed()

      Tests whether `closed()` has been called.
      Returns:
        whether `closed()` has been called.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`