AgeFileFilter (Commons IO 2.5)
Date: 2016-12-01

org.apache.commons.io.filefilter

## Class AgeFileFilter

- java.lang.Object
- - org.apache.commons.io.filefilter.AbstractFileFilter
  - - org.apache.commons.io.filefilter.AgeFileFilter

- All Implemented Interfaces:
    java.io.FileFilter, java.io.FilenameFilter, java.io.Serializable, IOFileFilter

      public class AgeFileFilter
      extends AbstractFileFilter
      implements java.io.Serializable

  Filters files based on a cutoff time, can filter either newer files or files equal to or older.

  For example, to print all files and directories in the current directory older than one day:

       File dir = new File(".");
       // We are interested in files older than one day
       long cutoff = System.currentTimeMillis() - (24 * 60 * 60 * 1000);
       String[] files = dir.list( new AgeFileFilter(cutoff) );
       for ( int i = 0; i < files.length; i++ ) {
           System.out.println(files[i]);
       }

  Since:
    1.2
  Version:
    $Id: AgeFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
  See Also:
    `FileFilterUtils.ageFileFilter(Date)`, `FileFilterUtils.ageFileFilter(File)`, `FileFilterUtils.ageFileFilter(long)`, `FileFilterUtils.ageFileFilter(Date, boolean)`, `FileFilterUtils.ageFileFilter(File, boolean)`, `FileFilterUtils.ageFileFilter(long, boolean)`, Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private boolean` | `acceptOlder` Whether the files accepted will be older or newer.
    `private long` | `cutoff` The cutoff time threshold.
    `private static long` | `serialVersionUID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AgeFileFilter(java.util.Date cutoffDate)` Constructs a new age file filter for files older than (at or before) a certain cutoff date.
    `AgeFileFilter(java.util.Date cutoffDate, boolean acceptOlder)` Constructs a new age file filter for files on any one side of a certain cutoff date.
    `AgeFileFilter(java.io.File cutoffReference)` Constructs a new age file filter for files older than (at or before) a certain File (whose last modification time will be used as reference).
    `AgeFileFilter(java.io.File cutoffReference, boolean acceptOlder)` Constructs a new age file filter for files on any one side of a certain File (whose last modification time will be used as reference).
    `AgeFileFilter(long cutoff)` Constructs a new age file filter for files equal to or older than a certain cutoff
    `AgeFileFilter(long cutoff, boolean acceptOlder)` Constructs a new age file filter for files on any one side of a certain cutoff.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `accept(java.io.File file)` Checks to see if the last modification of the file matches cutoff favorably.
    `java.lang.String` | `toString()` Provide a String representaion of this file filter.

    - ### Methods inherited from class org.apache.commons.io.filefilter.AbstractFileFilter

      `accept`

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

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

- - ### Field Detail

    - #### serialVersionUID

          private static final long serialVersionUID

      See Also:
        Constant Field Values

    - #### cutoff

          private final long cutoff

      The cutoff time threshold.

    - #### acceptOlder

          private final boolean acceptOlder

      Whether the files accepted will be older or newer.

  - ### Constructor Detail

    - #### AgeFileFilter

          public AgeFileFilter(long cutoff)

      Constructs a new age file filter for files equal to or older than a certain cutoff
      Parameters:
        `cutoff` - the threshold age of the files

    - #### AgeFileFilter

          public AgeFileFilter(long cutoff,
                       boolean acceptOlder)

      Constructs a new age file filter for files on any one side of a certain cutoff.
      Parameters:
        `cutoff` - the threshold age of the files
        `acceptOlder` - if true, older files (at or before the cutoff) are accepted, else newer ones (after the cutoff).

    - #### AgeFileFilter

          public AgeFileFilter(java.util.Date cutoffDate)

      Constructs a new age file filter for files older than (at or before) a certain cutoff date.
      Parameters:
        `cutoffDate` - the threshold age of the files

    - #### AgeFileFilter

          public AgeFileFilter(java.util.Date cutoffDate,
                       boolean acceptOlder)

      Constructs a new age file filter for files on any one side of a certain cutoff date.
      Parameters:
        `cutoffDate` - the threshold age of the files
        `acceptOlder` - if true, older files (at or before the cutoff) are accepted, else newer ones (after the cutoff).

    - #### AgeFileFilter

          public AgeFileFilter(java.io.File cutoffReference)

      Constructs a new age file filter for files older than (at or before) a certain File (whose last modification time will be used as reference).
      Parameters:
        `cutoffReference` - the file whose last modification time is usesd as the threshold age of the files

    - #### AgeFileFilter

          public AgeFileFilter(java.io.File cutoffReference,
                       boolean acceptOlder)

      Constructs a new age file filter for files on any one side of a certain File (whose last modification time will be used as reference).
      Parameters:
        `cutoffReference` - the file whose last modification time is usesd as the threshold age of the files
        `acceptOlder` - if true, older files (at or before the cutoff) are accepted, else newer ones (after the cutoff).

  - ### Method Detail

    - #### accept

          public boolean accept(java.io.File file)

      Checks to see if the last modification of the file matches cutoff favorably.

      If last modification time equals cutoff and newer files are required, file IS NOT selected. If last modification time equals cutoff and older files are required, file IS selected.

      Specified by:
        `accept` in interface `java.io.FileFilter`
      Specified by:
        `accept` in interface `IOFileFilter`
      Overrides:
        `accept` in class `AbstractFileFilter`
      Parameters:
        `file` - the File to check
      Returns:
        true if the filename matches

    - #### toString

          public java.lang.String toString()

      Provide a String representaion of this file filter.
      Overrides:
        `toString` in class `AbstractFileFilter`
      Returns:
        a String representaion

Copyright (c) 2002-2016 Apache Software Foundation