org.apache.hc.core5.util

## Class Deadline

- java.lang.Object
- - org.apache.hc.core5.util.Deadline

-     public class Deadline
      extends Object

  A deadline based on a UNIX time, the elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970.
  Since:
    5.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DATE_FORMAT` The format used for parsing and formatting dates.
    `static Deadline` | `MAX_VALUE` The maximum (longest-lived) deadline.
    `static Deadline` | `MIN_VALUE` The minimum (shortest-lived) deadline.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Deadline` | `calculate(long timeMillis, TimeValue timeValue)` Calculates a deadline with a given time in milliseconds plus a given time value.
    `static Deadline` | `calculate(TimeValue timeValue)` Calculates a deadline from now plus a given time value.
    `boolean` | `equals(Object obj)`
    `String` | `format(TimeUnit overdueTimeUnit)` Formats this deadline.
    `String` | `formatTarget()` Formats the deadline value as a string in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".
    `Deadline` | `freeze()`
    `static Deadline` | `fromUnixMilliseconds(long value)` Creates a deadline from a UNIX time in milliseconds.
    `long` | `getValue()` Gets the UNIX time deadline value.
    `int` | `hashCode()`
    `boolean` | `isBefore(long millis)` Returns whether this deadline occurs before the given time in milliseconds.
    `boolean` | `isExpired()` Returns whether the deadline has expired.
    `boolean` | `isMax()` Returns whether this deadline is the maximum deadline.
    `boolean` | `isMin()` Returns whether this deadline is the minimum deadline.
    `boolean` | `isNotExpired()` Returns whether this deadline has not expired.
    `Deadline` | `min(Deadline other)` Returns the smaller of this and another `Deadline`.
    `static Deadline` | `parse(String source)` Creates a deadline from a string in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".
    `long` | `remaining()` Returns the difference in milliseconds between the deadline and now.
    `TimeValue` | `remainingTimeValue()` Returns the difference as a TimeValue between the deadline and now.
    `String` | `toString()`

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

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

- - ### Field Detail

    - #### DATE_FORMAT

          public static final String DATE_FORMAT

      The format used for parsing and formatting dates.
      See Also:
        Constant Field Values

    - #### MAX_VALUE

          public static Deadline MAX_VALUE

      The maximum (longest-lived) deadline.

    - #### MIN_VALUE

          public static Deadline MIN_VALUE

      The minimum (shortest-lived) deadline.

  - ### Method Detail

    - #### calculate

          public static Deadline calculate(long timeMillis,
                                           TimeValue timeValue)

      Calculates a deadline with a given time in milliseconds plus a given time value. Non-positive time values represent an indefinite timeout without a deadline.
      Parameters:
        `timeMillis` - A time in UNIX milliseconds, usually the current time.
        `timeValue` - time value to add to `timeMillis`.
      Returns:
        a deadline representing the current time plus the given time value.

    - #### calculate

          public static Deadline calculate(TimeValue timeValue)

      Calculates a deadline from now plus a given time value. Non-positive time values represent an indefinite timeout without a deadline.
      Parameters:
        `timeValue` - time value to add to `timeMillis`.
      Returns:
        a deadline representing the current time plus the given time value.

    - #### fromUnixMilliseconds

          public static Deadline fromUnixMilliseconds(long value)

      Creates a deadline from a UNIX time in milliseconds.
      Parameters:
        `value` - a UNIX time in milliseconds.
      Returns:
        a new deadline.

    - #### parse

          public static Deadline parse(String source)
                                throws ParseException

      Creates a deadline from a string in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".
      Parameters:
        `source` - a string in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".
      Returns:
        a deadline from a string in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".
      Throws:
        `ParseException` - if the specified source string cannot be parsed.

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### format

          public String format(TimeUnit overdueTimeUnit)

      Formats this deadline.
      Parameters:
        `overdueTimeUnit` - the time unit to show how much over the deadline we are.
      Returns:
        a formatted string.

    - #### formatTarget

          public String formatTarget()

      Formats the deadline value as a string in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".
      Returns:
        a formatted string in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".

    - #### freeze

          public Deadline freeze()

    - #### getValue

          public long getValue()

      Gets the UNIX time deadline value.
      Returns:
        the UNIX time deadline value.

    - #### isBefore

          public boolean isBefore(long millis)

      Returns whether this deadline occurs before the given time in milliseconds.
      Parameters:
        `millis` - the time to compare.
      Returns:
        whether this deadline occurs before the given time in milliseconds.

    - #### isExpired

          public boolean isExpired()

      Returns whether the deadline has expired.
      Returns:
        whether the deadline has expired.

    - #### isMax

          public boolean isMax()

      Returns whether this deadline is the maximum deadline.
      Returns:
        whether this deadline is the maximum deadline.

    - #### isMin

          public boolean isMin()

      Returns whether this deadline is the minimum deadline.
      Returns:
        whether this deadline is the minimum deadline.

    - #### isNotExpired

          public boolean isNotExpired()

      Returns whether this deadline has not expired.
      Returns:
        whether this deadline has not expired.

    - #### min

          public Deadline min(Deadline other)

      Returns the smaller of this and another `Deadline`.
      Parameters:
        `other` - another deadline.
      Returns:
        the smaller of `this` and `other`.

    - #### remaining

          public long remaining()

      Returns the difference in milliseconds between the deadline and now.
      Returns:
        the different in milliseconds between the deadline and now.

    - #### remainingTimeValue

          public TimeValue remainingTimeValue()

      Returns the difference as a TimeValue between the deadline and now.
      Returns:
        Returns the different as a TimeValue between the deadline and now.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2005–2022 The Apache Software Foundation. All rights reserved.