TimeComparison (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.types, class: TimeComparison

Package org.apache.tools.ant.types

# Class TimeComparison

java.lang.Object
org.apache.tools.ant.types.EnumeratedAttribute
org.apache.tools.ant.types.TimeComparison

Direct Known Subclasses:
  `DateSelector.TimeComparisons`

public class TimeComparison extends EnumeratedAttribute
EnumeratedAttribute for time comparisons. Accepts values "before", "after", "equal".

Since:
  Ant 1.7

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final TimeComparison`
  `AFTER`
  After Comparison.
  `static final TimeComparison`
  `BEFORE`
  Before Comparison.
  `static final TimeComparison`
  `EQUAL`
  Equal Comparison.

  ### Fields inherited from class org.apache.tools.ant.types.EnumeratedAttribute

  `value`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TimeComparison()`
  Default constructor.
  `TimeComparison(String value)`
  Construct a new TimeComparison with the specified value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static int`
  `compare(long t1, long t2)`
  Compare two times.
  `static int`
  `compare(long t1, long t2, long g)`
  Compare two times.
  `boolean`
  `evaluate(long t1, long t2)`
  Evaluate two times against this TimeComparison.
  `boolean`
  `evaluate(long t1, long t2, long g)`
  Evaluate two times against this TimeComparison.
  `String[]`
  `getValues()`
  Return the possible values.

  ### Methods inherited from class org.apache.tools.ant.types.EnumeratedAttribute

  `containsValue, getIndex, getInstance, getValue, indexOfValue, setValue, toString`

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

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

- ## Field Details

  - ### BEFORE

    public static final TimeComparison BEFORE
    Before Comparison.

  - ### AFTER

    public static final TimeComparison AFTER
    After Comparison.

  - ### EQUAL

    public static final TimeComparison EQUAL
    Equal Comparison.

- ## Constructor Details

  - ### TimeComparison

    public TimeComparison()
    Default constructor.

  - ### TimeComparison

    public TimeComparison(String value)
    Construct a new TimeComparison with the specified value.
    Parameters:
      `value` - the EnumeratedAttribute value.

- ## Method Details

  - ### getValues

    public String[] getValues()
    Return the possible values.
    Specified by:
      `getValues` in class `EnumeratedAttribute`
    Returns:
      String[] of EnumeratedAttribute values.

  - ### evaluate

    public boolean evaluate(long t1, long t2)
    Evaluate two times against this TimeComparison.
    Parameters:
      `t1` - the first time to compare.
      `t2` - the second time to compare.
    Returns:
      true if the comparison result fell within the parameters of this TimeComparison.

  - ### evaluate

    public boolean evaluate(long t1, long t2, long g)
    Evaluate two times against this TimeComparison.
    Parameters:
      `t1` - the first time to compare.
      `t2` - the second time to compare.
      `g` - the timestamp granularity.
    Returns:
      true if the comparison result fell within the parameters of this TimeComparison.

  - ### compare

    public static int compare(long t1, long t2)
    Compare two times.
    Parameters:
      `t1` - the first time to compare.
      `t2` - the second time to compare.
    Returns:
      a negative integer, a positive integer, or zero as t1 is before, after, or equal to t2 accounting for the default granularity.

  - ### compare

    public static int compare(long t1, long t2, long g)
    Compare two times.
    Parameters:
      `t1` - the first time to compare.
      `t2` - the second time to compare.
      `g` - the timestamp granularity.
    Returns:
      a negative integer, a positive integer, or zero as t1 is before, after, or equal to t2 accounting for the specified granularity.