<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import java.io.*;
import java.util.*;

/**
 * A DirectoryComparator that uses the last modified time to determine
 * order
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class DirectoryDateComparator extends DirectoryComparator
{

    /**
     * Compare two File objects for order based on their
     * last modified time
     * 
     * @param  firstFile   The first File object
     * @param  secondFile  The second File object
     * @return             -1/0/1 for "less than"/"equal to"/"greater than"
     */
    public int compare(File firstFile, File secondFile)
    {
	int          comparison;
        long         firstModified, secondModified;


	firstModified  = firstFile.lastModified();
	secondModified = secondFile.lastModified();

	// Call the compare method with long parameters
	comparison = 0;
        if      (firstModified &gt; secondModified) comparison =  1;
        else if (firstModified &lt; secondModified) comparison = -1;

	return comparison;
    }

}
</pre></body></html>